Module crypto

Data Types

cipher_iv()


cipher_iv() = aes_128_cbc | aes_192_cbc | aes_256_cbc | aes_128_cfb128 | aes_192_cfb128 | aes_256_cfb128 | aes_128_ctr | aes_192_ctr | aes_256_ctr

cipher_no_iv()


cipher_no_iv() = aes_128_ecb | aes_192_ecb | aes_256_ecb

crypto_opt()


crypto_opt() = {encrypt, boolean()} | {padding, padding()}

crypto_opts()


crypto_opts() = [crypto_opt()]

digest()


digest() = binary()

hash_algorithm()


hash_algorithm() = md5 | sha | sha224 | sha256 | sha384 | sha512

padding()


padding() = none | pkcs_padding

Function Index

crypto_one_time/4 Encrypted/decrypt data using given cipher and key.
crypto_one_time/5 Encrypted/decrypt data using given cipher, key, IV.
hash/2 Hash data using a specified hash algorithm.

Function Details

crypto_one_time/4


crypto_one_time(Cipher::cipher_no_iv(), Key::iodata(), Data::iodata(), FlagOrOptions::crypto_opts()) -> binary()

Cipher: a supported cipher
Key: the encryption / decryption key
Data: to be crypted or encrypted
FlagOrOptions: either just true for encryption (or false for decryption), or a proplist for any additional option

returns: Returns crypted or encrypted data.

Encrypted/decrypt data using given cipher and key

crypto_one_time/5


crypto_one_time(Cipher::cipher_iv(), Key::iodata(), IV::iodata(), Data::iodata(), FlagOrOptions::crypto_opts()) -> binary()

Cipher: a supported cipher that makes use of IV
Key: the encryption / decryption key
IV: an initialization vector
Data: to be crypted or encrypted
FlagOrOptions: either just true for encryption (or false for decryption), or a proplist for any additional option such as padding.

returns: Returns crypted or encrypted data.

Encrypted/decrypt data using given cipher, key, IV.

hash/2


hash(Type::hash_algorithm(), Data::iolist()) -> digest()

Type: the hash algorithm
Data: the data to hash

returns: Returns the result of hashing the supplied data using the supplied hash algorithm.

Hash data using a specified hash algorithm.