add self encryption
This commit is contained in:
parent
bc95a6e403
commit
7d9d5fad53
|
@ -19,4 +19,5 @@ public:
|
|||
private:
|
||||
std::map<int64_t, std::string> chatKeyMap;
|
||||
bool dirty = true;
|
||||
std::string self;
|
||||
};
|
||||
|
|
|
@ -35,6 +35,10 @@ std::string Crypt::encryptForChat(int64_t chat, const std::string& message) {
|
|||
.setFDMode(Y::SubProcess::FD::ALL, Y::SubProcess::FDMode::Pipe)
|
||||
;
|
||||
|
||||
if(!self.empty()) {
|
||||
builder.addArgs({"--encrypt-to", self});
|
||||
}
|
||||
|
||||
std::unique_ptr<Y::SubProcess> proc = builder.start();
|
||||
|
||||
std::string out;
|
||||
|
@ -113,8 +117,12 @@ void Crypt::load() {
|
|||
std::string key;
|
||||
int64_t chat = 0;
|
||||
in >> chat >> key;
|
||||
if(chat && !key.empty()) {
|
||||
chatKeyMap[chat] = key;
|
||||
if(!key.empty()) {
|
||||
if(chat == 0) {
|
||||
self = key;
|
||||
} else {
|
||||
chatKeyMap[chat] = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
dirty = false;
|
||||
|
|
Loading…
Reference in New Issue