Skip to content

token generation

Nodejs Random Token Generation

import crypto from 'crypto'; // Built into nodejs

crypto.randomBytes(24, function(err, buffer) {
    var token = buffer.toString('hex');
    console.log(token)
});

async function doAsync() {
async function GenerateToken() {
        let token = await crypto.randomBytes(24).toString('hex')
        return token
    }
    console.log(await GenerateToken())
}
doAsync()

Research