Documentation: Generating hashes
This documentation provides an overview and explanation of the generateHash
function, which is responsible for generating a SHA-512 hash of a given string in hexadecimal format.
Importing the Function
hashing.ts
import { generateHash } from '@skiff-org/skiff-crypto';
Overview
The generateHash
function takes a string as input and generates a hash using the SHA-512 algorithm. The hashed value is then converted to a hexadecimal format and returned.
Function Signature
generateHash(value: string): string
- Description: Generates a hexadecimal SHA-512 hash of the given string.
- Parameters:
value: string
- The string to be hashed.
- Returns: A string representing the hashed value in hexadecimal format.
Example Usage
hashing.ts
import { generateHash } from '@skiff-org/skiff-crypto';
// Input string
const inputString = "This is a string to be hashed.";
// Generate hash
const hashedValue = generateHash(inputString);
// Output the hashed value
console.log(`Hashed Value: ${hashedValue}`);
Note
Keep in mind that SHA-512 is a cryptographic hash function, and it's generally used for integrity verification or fingerprinting, not for storing sensitive data like passwords. If you need to securely hash sensitive data like passwords, consider using a password hashing algorithm like bcrypt or Argon2.