Compare a value with a hashed value.
The value to compare.
The hashed value to compare against.
true
if the values match, false
otherwise.
This method compares a plain text value with a hashed value by rehashing the plain text value with the salt extracted from the hashed value.
// Example usage of compare method
const hashedValue = 'value:salt'
const isMatch = cryptoService.compare('mySecretValue', hashedValue);
Generate a random salt value of the specified number of rounds.
The number of rounds to generate the salt.
The generated salt value.
This method generates a random salt value using the crypto module.
// Example usage of genSalt method
const randomSalt = cryptoService.genSalt(10);
Generate a hashed value using SHA-512 algorithm with an optional salt.
The value to be hashed.
Optional
salt: stringAn optional salt value. If not provided, a random salt will be generated.
The hashed value appended with the salt.
This method uses the SHA-512 algorithm to hash the input value with the provided or generated salt.
// Example usage of hash method
const salt = cryptoService.genSalt(8)
const hashedValue = cryptoService.hash('mySecretValue', salt);
Generated using TypeDoc
Service for handling cryptographic operations.
Remarks
This service provides methods for hashing, comparing, and generating salt for cryptographic operations.