Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. module.exports = (length) => {
  2. // Character map
  3. const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0987654321' + Date.now()
  4.  
  5. // Process variables
  6. const charactersLength = characters.length
  7. const output = ''
  8.  
  9. // Random number generation
  10. const max = charactersLength - 1
  11. const min = 0
  12.  
  13. // Generate random characters
  14. for (i = length; i > 0; i--) {
  15. output += characters[Math.floor(Math.random() * (max - min + 1)) + min]
  16. }
  17.  
  18. return output
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement