-
Notifications
You must be signed in to change notification settings - Fork 0
API
MustafaHi edited this page Nov 3, 2021
·
4 revisions
After you built the library include file:
Botan.mjs || Botan.tis
The binding library API offers:
- Hashing (SHA-256, MD5...)
- Password Hashing (Argon2, Bcrypt)
- Encoding & Decoding (Base64, Hex)
- Encrypting & Decrypting (AES, Twofish...)
- Other Utilities
! The API is very data sensitive, invalid data may lead to crash
Hash a string using given method https://botan.randombit.net/handbook/api_ref/hash.html
Code:
Botan.hash(string: method, string: data)
Return: Hex encoded hash
Generate password hashing using methods [argon, bcrypt] https://botan.randombit.net/handbook/api_ref/passhash.html
Generate Methods : argon, bcrypt
await Botan.password(string: method, string: data)
Return: String
Check Methods : check-argon, check-bcrypt
await Botan.password(string: method, string: data, string: hash)
Return: Boolean
Methods : base64, hex
Encode
Botan.encode(string: method, string: data);
Return: String
Decode
Botan.decode(string: method, encoded-string: data);
Return: String
Encrypt
- Key must be of specified length per method requirement, you should hash it.
- If IV(nonce) is provided it will be used to encrypt the data, otherwise a new one is generated.
await Botan.cipher(string: method, string: data, hash-string: key [,hex-string: iv]);
Return: Object with data and iv
Decrypt
- Key must be of specified length per method requirement, you should hash it.
- IV(nonce) must be provided
await Botan.decipher(string: method, hex-string: data, hash-string: key, hex-string: iv)
Return: Object with data and iv
method : https://botan.randombit.net/handbook/api_ref/block_cipher.html
Botan.iv(string: method)
Return: String