The module provides functions to compute cryptographic hashes, encrypt and decrypt data, produce cryptographically secure pseudo-random number sequences
namespace crypto
Functions:
- hash(str: string, method: enum<md5,sha1>) => string
- encrypt(source: string, key: string, format: enum<regular,hex> = $regular) => string
- decrypt(source: string, key: string, format: enum<regular,hex> = $regular) => string
- random(count: int) => string
hash(str: string, method: enum<md5,sha1>) => stringReturns hash string of str using the specified method
encrypt(source: string, key: string, format: enum<regular,hex> = $regular) => stringEncrypts source with XXTEA algorithm using the given key. Returns the resulting data in the specified format
Errors: Crypto when source or key are not valid
decrypt(source: string, key: string, format: enum<regular,hex> = $regular) => stringDecrypts source with XXTEA algorithm using the given key. Returns the resulting data in the specified format
Errors: Crypto when source or key are not valid
random(count: int) => stringReturns binary string of count bytes read from system random number generator (uses /dev/urandom on Unix, CryptGenRandom() on Windows)
Errors: Crypto if failed to use system RNG