| 244 | } |
| 245 | |
| 246 | static 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 | |
| 261 | static std::string encrypt_string(td::Slice S, td::Slice secret) { |
| 262 | auto enc_value = tde2e_core::MessageEncryption::encrypt_data(S, secret); |
no test coverage detected