Secure random token in Node.js

后端 未结 12 971
盖世英雄少女心
盖世英雄少女心 2020-11-28 00:05

In this question Erik needs to generate a secure random token in Node.js. There\'s the method crypto.randomBytes that generates a random Buffer. However, the ba

12条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 01:06

    Synchronous option in-case if you are not a JS expert like me. Had to spend some time on how to access the inline function variable

    var token = crypto.randomBytes(64).toString('hex');
    

提交回复
热议问题