pro118njsac/pro118njsac-back-b/authsec_node/Backend/Functions/generateRandomHash.js

14 lines
300 B
JavaScript
Raw Normal View History

2024-09-16 05:00:58 +00:00
const crypto = require("crypto")
function generateRandomHash(length = 32) {
// Generate random bytes
const randomBytes = crypto.randomBytes(length)
// Convert bytes to hexadecimal representation
const hash = randomBytes.toString("hex")
return hash
}
module.exports = generateRandomHash