flightworker-atk-auth
Version:
## 中间件部署
18 lines (15 loc) • 457 B
JavaScript
const crypto = require('crypto')
const randomMax = max => Math.floor(Math.random()* max)
const md5 = str => {
const md5 = crypto.createHash("md5")
md5.update(str)
return md5.digest('hex')
}
exports = module.exports = {
key(len, prefix){
const key = parseInt(Math.random() * 10000000)
const token = md5(`${key}-${new Date - 0}@${prefix || ''}`)
return len ? token.substr(randomMax(len)) : token
}
}