Skip to content
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:

  1. Hashing (SHA-256, MD5...)
  2. Password Hashing (Argon2, Bcrypt)
  3. Encoding & Decoding (Base64, Hex)
  4. Encrypting & Decrypting (AES, Twofish...)
  5. Other Utilities

! The API is very data sensitive, invalid data may lead to crash


Hash

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


Password

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


Codec

Methods : base64, hex

Encode

Botan.encode(string: method, string: data);

Return: String

Decode

Botan.decode(string: method, encoded-string: data);

Return: String


Cipher

Encrypt

  1. Key must be of specified length per method requirement, you should hash it.
  2. 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

  1. Key must be of specified length per method requirement, you should hash it.
  2. 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


Utilities

IV(nonce)

method : https://botan.randombit.net/handbook/api_ref/block_cipher.html

Botan.iv(string: method)

Return: String

Clone this wiki locally