Synapse Cryptography Library
Namespaces
- syn.crypt.base64
- syn.crypt.hex
- syn.crypt.lz4
- syn.crypt.zstd
- syn.crypt.derive
- syn.crypt.user
- syn.crypt.seal
- syn.crypt.sign
- syn.crypt.custom
- syn.crypt.url
Functions
encrypt
string syn.crypt.encrypt(data: string, key: string, additional_data?: string)
Encrypts data
with key
, and includes additional_data
if it is passed.
(Uses libsodium secretbox for when additional_data
isn't passed, and the AEAD form of the same algorithm if it is passed. Nonce is generated and appended before the encrypted message.)
decrypt
string syn.crypt.decrypt(ciphertext: string, key: string, additional_data?: string)
Decrypts ciphertext
with key
. The data (along with additional_data
if it is passed) is also authenticated via a MAC before being returned.
(Uses libsodium secretbox or the AEAD form if additional_data
is passed, like above.)
hash
string syn.crypt.hash(data: string, key?: string)
Hashes data
with Blake2B. Optionally, you can pass key
to create a 'keyed' hash, for which the hash will never be the same for different keys.
(Uses libsodium generic hashing.)
hmac
string syn.crypt.hmac(data: string, key: string)
Creates a HMAC signature from data
and key
. Note this is not the same as passing a key
to the above function, and uses a different algorithm.
(Uses libsodium authentication.)
random
string syn.crypt.random(len: uint)
Generates a random string with size
(cannot be negative or exceed 1024).