Skip to content

Instantly share code, notes, and snippets.

@ixqbar
Created February 2, 2017 09:21
Show Gist options
  • Save ixqbar/6f4946ebdddc2801542b0c9380930d9b to your computer and use it in GitHub Desktop.
Save ixqbar/6f4946ebdddc2801542b0c9380930d9b to your computer and use it in GitHub Desktop.
JS
var getKey = function(length){
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789;<>,./?{}[]!@#$%^&*(()";

    for( var i=0; i < length; i++ )
        text += possible.charAt(Math.floor(Math.random() * possible.length));
    return text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment