Created
May 3, 2020 14:47
-
-
Save TonyDotDev/c8f8ad4764982cc1836a44cbdd55e208 to your computer and use it in GitHub Desktop.
Generates a random secret
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const base32 = require('hi-base32'); | |
export default function generateSecret(length = 20) { | |
const randomBuffer = crypto.randomBytes(length); | |
return base32.encode(randomBuffer).replace(/=/g, ''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment