Skip to main content

decrypt

Function decrypt 

Source
pub fn decrypt(
    message: &str,
    password: &str,
) -> Result<String, ValidationErrors>
Expand description

Decrypts a Base64-encoded payload produced by encrypt and returns the original message.

Reverses the three stages of encrypt:

  1. Base64 decode — unpacks the payload back into salt, nonce, and ciphertext.
  2. AES-256-GCM — decrypts and authenticates the ciphertext. Fails if the payload was tampered with or if the wrong password is provided.
  3. SGA decode — converts SGA symbols back to plain ASCII letters.

§Errors

Returns an error if the payload is malformed, authentication fails, or decoding fails.

§Example

let plaintext = ender_eye::decrypt(&ciphertext, "my-password").unwrap();
assert_eq!(plaintext, "hello world");