Skip to main content

encrypt

Function encrypt 

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

Encrypts a message using a password and returns a Base64-encoded payload.

Internally runs the message through three stages:

  1. SGA encoding — substitutes each letter with its Standard Galactic Alphabet symbol.
  2. AES-256-GCM — encrypts the encoded text. A random salt and nonce are generated on every call, so two calls with identical inputs will always produce different outputs.
  3. Base64 — packs salt + nonce + ciphertext into a single portable string.

§Errors

Returns an error if encryption fails.

§Example

let ciphertext = ender_eye::encrypt("hello world", "my-password").unwrap();