Aes-Encrypt

(aes-encrypt aes-key string) -> encrypted-string

Encrypts the given string using the AES encryption standard, with the given key. If the string is less than 16 bytes in length, padding will be added to make it 16 bytes. If the string is greater than 16 bytes in length, an error will be thrown.

The output is not human-readable. If output to the console, the resulting string may not be pasted back in. If it is necessary to have human-readable output, wrap aes-encrypt in base64-encode.

Examples:
In both examples, 'a' is a previously defined aes-key.

>> (define b (aes-encrypt a "abcdefghijklmnop"))
:: #f
>> (aes-decrypt a b)
:: "abcdefghijklmnop"
>> (base64-encode (aes-encrypt a "abcdefghijklmnop"))
:: "cHq7T8tviX1PiBsOzxePXw=="
>> (aes-decrypt a (base64-decode "cHq7T8tviX1PiBsOzxePXw=="))
:: "abcdefghijklmnop"

See Also: <aes-key>, base64-decode