use crate::core::errors::{StorageError, StorageResult};
pub use foundation_compact::crypto::chacha::ChaChaKey as EncryptionKey;
pub use foundation_compact::crypto::{SecureBytes, SecureString};
pub fn encrypt(key: &EncryptionKey, plaintext: &[u8]) -> StorageResult<Vec<u8>> {
foundation_compact::crypto::chacha::encrypt(key, plaintext)
.map_err(StorageError::Encryption)
}
pub fn decrypt(key: &EncryptionKey, encrypted: &[u8]) -> StorageResult<SecureBytes> {
foundation_compact::crypto::chacha::decrypt(key, encrypted)
.map_err(StorageError::Encryption)
}