MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / decrypt_string

Function decrypt_string

runners/helpers/ValidateRequest.cpp:246–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246static td::Result<std::string> decrypt_string(td::Slice S, td::Slice secret) {
247 auto encryption_type = S.copy().truncate(4);
248 S.remove_prefix(4);
249
250 if (encryption_type == "ENC_") {
251 TRY_RESULT(v, td::hex_decode(S));
252 TRY_RESULT(res, tde2e_core::MessageEncryption::decrypt_data(v, secret));
253 return res.as_slice().str();
254 } else if (encryption_type == "DEC_") {
255 return S.str();
256 } else {
257 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << "bad encryption method: " << S);
258 }
259}
260
261static std::string encrypt_string(td::Slice S, td::Slice secret) {
262 auto enc_value = tde2e_core::MessageEncryption::encrypt_data(S, secret);

Callers 1

decrypt_all_stringsFunction · 0.85

Calls 2

as_sliceMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected