Global

Members

crypto

Functions for AES256-GCM encryption/decryption and Argon2 hashing.
This module provides functions to generate an AES key, encrypt and decrypt messages, and hash and verify passwords using Argon2.
It uses the PyCryptodome library for AES encryption and Argon2 for password hashing.
It is important to note that the AES key should be kept secret and secure.
The Argon2 hash should also be stored securely, as it is used to verify passwords.
This module is intended for educational purposes and should not be used in production without proper security measures.
Version:
  • 1.0.3
Author:
  • RAFAEL PERAZZO B MOTA
Source:

Methods

author() → {string}

Returns the author of the module.
Source:
Returns:
- The author of the module.
Type
string

decrypt_gcm(text, key) → {string}

Decrypts a message using AES256-GCM encryption.
Parameters:
Name Type Description
text string The message to decrypt.
key Uint8Array The AES key to use for decryption.
Source:
Returns:
- The decrypted message.
Type
string

encrypt_gcm(text, key) → {string}

Encrypts a message using AES256-GCM encryption.
Parameters:
Name Type Description
text string The message to encrypt.
key Uint8Array The AES key to use for encryption.
Source:
Returns:
- The encrypted message in hex format.
Type
string

(async) hashPassword(password) → {string}

Hashes a password using Argon2.
Parameters:
Name Type Description
password string The password to hash.
Source:
Returns:
- The hashed password.
Type
string

hexString2bytes(hexString) → {Uint8Array}

Converts a hex string to a Uint8Array.
Parameters:
Name Type Description
hexString string The hex string to convert.
Source:
Returns:
- The converted Uint8Array.
Type
Uint8Array

hmac(key, data) → {string}

Generates a HMAC using SHA3-512.
Parameters:
Name Type Description
key Uint8Array The key to use for HMAC generation.
data string The data to hash.
Source:
Returns:
- The HMAC in hex format.
Type
string

(async) verifyPassword(password, hash) → {boolean}

Verifies a password against a hash using Argon2.
Parameters:
Name Type Description
password string The password to verify.
hash string The hash to verify against.
Source:
Throws:
- If the password does not match the hash.
Type
Error
Returns:
- True if the password matches the hash, false otherwise.
Type
boolean