crypt

Documentation of Synapse Z crypt library

crypt.encrypt

string crypt.encrypt(data: string, key: string, additional_data: string?)

uses libsodium secretbox or aead if additonal_data is provided, nonce is appended to the start

crypt.decrypt

string crypt.decrypt(data: string, key: string, additional_data: string?)

uses libsodium secretbox or aead if additonal_data is provided

crypt.hash

string crypt.hash(data: string, key: string?)

uses blake2b_sha512 with optional key

crypt.hmac

string crypt.hmac(data: string, key: string)

uses libsodium auth

crypt.random

string crypt.random(size: number)

generates a random string with the specified size (size >= 0 and size <= 1024)

crypt.generatebytes

string crypt.generatebytes(size: number)

generates a random string with the specified size (size >= 0 and size <= 1024) and encodes it using base64

crypt.generatekey

string crypt.generatekey()

equal to crypt.generatebytes(32)