pub fn encrypt_bytes(plaintext: &[u8]) -> Result<String, CryptoError>Expand description
Encrypt raw bytes and return a versioned ASCII ciphertext string.
Output format:
v1:nonce_b64:ciphertext_b64
Where:
nonce_b64is 12 random bytes (URL-safe base64, no padding)ciphertext_b64includes the GCM authentication tag
§Key behavior
This function auto-initializes the master key if missing (first run).
§Example
use keycrypt::{encrypt_bytes, decrypt_bytes};
let enc = encrypt_bytes(b"hello")?;
let dec = decrypt_bytes(&enc)?;
assert_eq!(dec.as_slice(), b"hello");§Errors
CryptoError::Keychainif the OS keychain is unavailable.CryptoError::EncryptionFailedon cryptographic failure (rare).