This commit is contained in:
2024-08-02 09:50:53 -05:00
parent 9f76f20ea8
commit 4015c1bb6e
2 changed files with 14 additions and 7 deletions

View File

@ -68,7 +68,9 @@ decrypt_data(const key_type &key, const unsigned char *buffer,
template <typename buffer, typename result>
[[nodiscard]] inline auto decrypt_data(const key_type &key, const buffer &buf,
result &res) -> bool {
return decrypt_data<result>(key, buf.data(), buf.size(), res);
return decrypt_data<result>(
key, reinterpret_cast<const unsigned char *>(buf.data()), buf.size(),
res);
}
template <typename buffer, typename result>
@ -134,13 +136,15 @@ inline void encrypt_data(std::string_view encryption_token,
template <typename buffer, typename result>
inline void encrypt_data(std::string_view encryption_token, const buffer &buf,
result &res) {
encrypt_data<result>(generate_key(encryption_token), buf.data(), buf.size(),
res);
encrypt_data<result>(generate_key(encryption_token),
reinterpret_cast<const unsigned char *>(buf.data()),
buf.size(), res);
}
template <typename buffer, typename result>
inline void encrypt_data(const key_type &key, const buffer &buf, result &res) {
encrypt_data<result>(key, buf.data(), buf.size(), res);
encrypt_data<result>(key, reinterpret_cast<const unsigned char *>(buf.data()),
buf.size(), res);
}
template <typename buffer, typename result>
@ -148,7 +152,9 @@ inline void
encrypt_data(const std::array<unsigned char,
crypto_aead_xchacha20poly1305_IETF_NPUBBYTES> &iv,
const key_type &key, const buffer &buf, result &res) {
encrypt_data<result>(iv, key, buf.data(), buf.size(), res);
encrypt_data<result>(iv, key,
reinterpret_cast<const unsigned char *>(buf.data()),
buf.size(), res);
}
} // namespace repertory::utils::encryption