Last active
          April 23, 2018 13:28 
        
      - 
      
- 
        Save dvgamerr/7fd5f0191dc567b8542b28206e486fbd to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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
    
  
  
    
  | let charType = () => { | |
| let group = [ 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2 ] | |
| return group[parseInt(Math.random() * group.length)] | |
| } | |
| let charASCII = t => parseInt(Math.random() * (t === 0 ? 9 : 25)) | |
| const randomString = l => { | |
| l = l || 32 | |
| let result = '' | |
| for (let i = 0; i < l; i++) { | |
| let t = charType() | |
| let n = charASCII(t) | |
| result += t === 0 ? n.toString() : String.fromCharCode(t === 1 ? 97 + n : 65 + n) | |
| } | |
| return result | |
| } | |
| console.log('random:', randomString(16)) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment