mardi 18 août 2015

how to generate numbers randomly in a secured way in Java Script?

I want to generate the numbers randomly in a secured way.

I have been using the Math.random() previously like in the code

url += "abixmlrequest=true&abi_rand=" + Math.random();

I need to use now cryptoObj.getRandomValues(typedArray);

Is the below code is correct:

var crypto = window.crypto || window.msCrypto;
var array = new Uint32Array(10);
url += "abixmlrequest=true&abi_rand=" + crypto.getRandomValues(array);

Or else aybody suggest some other Function to generate a random number in a easier way and also secured.

Thanks in Advance.




Aucun commentaire:

Enregistrer un commentaire