Function present::encrypt_str [] [src]

pub fn encrypt_str<K: Key>(text: &str, key: &K, mode: &OpMode) -> (Vec<u8>, Option<Block>)

Encrypt a string.

Encrypt a string with a specific key and operation mode. Because the ciphertext is not a valid UTF-8 string, it is instead returned as a byte vector. In addition, if the specified operation mode needs an initialization vector, one will be randomly generated and returned with the ciphertext.

Arguments

Examples

use present::{encrypt_str, Key80Bit, OpMode};
let key = Key80Bit::new([0xFF; 10]);
let (ciphertext, iv) = encrypt_str("Hello, world!", &key, &OpMode::CBC);
assert!(iv.is_some());Run