mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
simplify keygen
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
var crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function (length) {
|
||||||
var shasum = crypto.createHash('sha1')
|
if (!_.isFinite(length)) length = 12
|
||||||
shasum.update(((new Date()).getTime() + Math.round(Math.random()*1000)).toString())
|
return crypto.randomBytes(length).toString('hex')
|
||||||
return shasum.digest('hex')
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user