In this blog I am going to show you how to generate Random String/key of alpha-numeric values using java script, which may help us in many way like generate random key, any strong random password e.t.c
Here is function which generate random string.
var string=' ';
function randomString(){
var random_string=' '; // Empty Random String
var chars = "0123456789ABCDEFGHIJKL!@#$%^&* ()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; // Characters from where random string generate
var string_length = 5; //Length of random string
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
random_string += chars.substring(rnum,rnum+1); //generate random string
}
string=random_string; //here is your generated random string
alert(random_string);
}
enjoy with your random key. :)
Here is function which generate random string.
var string=' ';
function randomString(){
var random_string=' '; // Empty Random String
var chars = "0123456789ABCDEFGHIJKL!@#$%^&* ()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; // Characters from where random string generate
var string_length = 5; //Length of random string
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
random_string += chars.substring(rnum,rnum+1); //generate random string
}
string=random_string; //here is your generated random string
alert(random_string);
}
enjoy with your random key. :)
No comments:
Post a Comment