Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

crypto -- common cryptographic tasks

The module provides functions to compute cryptographic hashes, encrypt and decrypt data, produce cryptographically secure pseudo-random number sequences

Index

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

Functions

hash(str: string, method: enum<md5,sha1>) => string

Returns hash string of str using the specified method

encrypt(source: string, key: string, format: enum<regular,hex> = $regular) => string

Encrypts 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) => string

Decrypts 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) => string

Returns 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