| 113 | } |
| 114 | |
| 115 | EncryptedData parseEncrypted(const std::string& input) { |
| 116 | std::vector<std::string> nonce_and_rest = utils::StringUtils::split(input, EncryptionType::separator()); |
| 117 | if (nonce_and_rest.size() != 2) { |
| 118 | throw std::invalid_argument{"Incorrect input; expected '<nonce>" + EncryptionType::separator() + "<ciphertext_plus_mac>'"}; |
| 119 | } |
| 120 | |
| 121 | Bytes nonce = utils::StringUtils::from_base64(nonce_and_rest[0].data(), nonce_and_rest[0].size()); |
| 122 | Bytes ciphertext_plus_mac = utils::StringUtils::from_base64(nonce_and_rest[1].data(), nonce_and_rest[1].size()); |
| 123 | |
| 124 | return EncryptedData{nonce, ciphertext_plus_mac}; |
| 125 | } |
| 126 | |
| 127 | bool isEncrypted(const std::string& input) { |
| 128 | try { |
no test coverage detected