bcrypt
This module provides functions for generating and verifying bcrypt hashes as well as functions for getting information from a bcrypt hash.
Fields
- bcrypt.DEFAULT_LOG2_ROUNDS ➝ number
- Default log2 rounds (default: 10).
- bcrypt.MAX_EXECUTION_TIME ➝ number
- Maximum execution time for each cipher iteration in milliseconds (default: 100).
Functions
- bcrypt.hash(str, salt_length)
-
Generates a hash for the given string. If salt_length is not given, the length of the salt will be equal to
DEFAULT_LOG2_ROUNDS
.- @params:
- string str
- number? salt_length
- @returns: string
- @raises:
- Exception
- @params:
- bcrypt.compare(str, known_hash)
-
Tests a string against a known hash.
- @params:
- string str
- string known_hash
- @returns: bool
- @raises:
- Exception
- @params:
- bcrypt.get_rounds(hash)
-
Gets the number of rounds used to encrypt the specified hash.
- @params:
- string hash
- @returns: number
- @raises:
- Exception
- @params:
- bcrypt.get_salt(hash)
-
Gets the salt portion from a hash.
@notes:
- This function does not validate the hash.
- @params:
- string hash
- @returns: string
- @raises:
- Exception