Function guidon::gencrypt [−][src]
pub fn gencrypt(data: &str, key: Option<&str>) -> Result<String>
Encrypt a string with the given key
The key can be provided by an environment variable GUIDON_KEY
or by the key option.
As of now, the environment variable will be used if set, even if a key is provided as an
argument.
A initialization vector (IV) can also be provided by environment variable GUIDON_IV
. If not
the default on will be used. The IV must be 16 chars.
Arguments
data
: The message to encryptkey
: An option of the key to use. The key length should be 256.
Example
let key = "top_secret"; let enc_msg = gencrypt("Hello world !", Some(&key)).unwrap(); println!("{}", enc_msg);