lock-key.core

Wrapper around the Java cryptography extensions in javax.crypto. Implements
symmetric encryption in AES/CBC/PKCS5Padding mode.

decrypt

(decrypt value encryption-key)
Decrypts a value which has been encrypted via (encrypt). Returns byte[].

The first 16 bytes of the input value is the initialization vector to use when
decrypting. The remainder is the encrypted data.

value          - (byte[]) the value to decrypt
encryption-key - (String) the key with which the value was encrypted

decrypt-as-str

(decrypt-as-str value encryption-key)(decrypt-as-str value encryption-key charset)
Decryptes a value which has been encrypted via (encrypt) and attempts to
construct the decrypted value into a string.

value              - (byte[]) the value to decrypt
encryption-key     - (String) the key with which the value was encrypted
(optional) charset - (Charset) decodes the array of bytes using a specified charset. if not specified uses the default charset

decrypt-from-base64

(decrypt-from-base64 value encryption-key)(decrypt-from-base64 value encryption-key charset)
Decryptes a value which has been encrypted via (encrypt-as-base64) and attempts to
construct the decrypted value into a string.

value              - (String) the value to decrypt encoded as a base64 string
encryption-key     - (String) the key with which the value was encrypted
(optional) charset - (Charset) decodes the array of bytes using a specified charset. if not specified uses the default charset

encrypt

(encrypt value encryption-key)
Symmetrically encrypts value with encryption-key, such that it can be
decrypted later with (decrypt).

Returns byte[]. The first 16 bytes of the returned value are the
initialization vector. The remainder is the encrypted data.

value           - (String/byte[]) the value to encrypt. Throws IllegalArgumentException
                  if value is an invalid type.
encryption-key  - (String) the key with which to encrypt value with. Throws
                  IllegalArgumentException if encryption-key is empty

encrypt-as-base64

(encrypt-as-base64 value encryption-key)(encrypt-as-base64 value encryption-key charset)
Symmetrically encrypts value with encryption-key, returning a base64 encoded string, such that it can be
decrypted later with (decrypt-from-base64).

value              - (String/byte[]) the value to encrypt.
encryption-key     - (String) the key with which to encrypt value with.
(optional) charset - (Charset) decodes the array of bytes using a specified charset. if not specified uses the default charset