mardi 8 octobre 2019

How to replace Math.random() with crypto.getRandomValues() and keep same result?

I'am using the following function to get a specific random string to pass it then to another function:

function generateRandomString() {
    return Math.random().toString(36).substring(2, 15) + 
           Math.random().toString(36).substring(2, 15);
}

I would like to use crypto.getRandomValues() instead Math.random(). How would I pass Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); as an argument to the crypto.getRandomValues(), or I'am in the wrong direction?




Aucun commentaire:

Enregistrer un commentaire