Last active
November 25, 2021 04:23
-
-
Save MahouSirin/8fd0390ba5c77cd52a0d3cd986ff43ab to your computer and use it in GitHub Desktop.
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'); | |
module.exports = () => { | |
const time = Math.floor(Date.now() / 1000); | |
const DS_SALT = '6cqshh5dhw73bzxn20oexa9k516chk7s'; | |
const randomChar = randomString(6); | |
const data = `salt=${DS_SALT}&t=${time}&r=${randomChar}`; | |
const hash = crypto.createHash('md5').update(data).digest('hex'); | |
return `${time},${randomChar},${hash}`; | |
} | |
funcion randomString(len = 6, an) => { | |
an = an && an.toLowerCase(); | |
let str = ''; | |
let i = 0; | |
let min = an === 'a' ? 10 : 0; | |
let max = an === 'n' ? 10 : 62; | |
for (;i++ < len;) { | |
let r = Math.random() * (max - min) + min << 0; | |
str += String.fromCharCode(r += r > 9 ? r < 36 ? 55 : 61 : 48); | |
} | |
return str; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment