Skip to main content

decrypt_bytes

Function decrypt_bytes 

Source
pub fn decrypt_bytes<S: AsRef<str>>(
    encoded: S,
) -> Result<Zeroizing<Vec<u8>>, CryptoError>
Expand description

Decrypt an encoded ciphertext string into raw bytes.

Accepts either:

  • v1:nonce_b64:ciphertext_b64 (current)
  • nonce_b64:ciphertext_b64 (legacy)

§Key behavior

This function does not auto-initialize the key. If the key is missing, it returns CryptoError::KeyNotSet.

§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