jeudi 3 février 2022

How can we generate Random Salt of 32 bytes in Rhino JS

I am trying to generate a random salt of 32 bytes size. But my JS engine Rhino 1.7.13 doesn't support SecureRandom class.

Below is the code snippet of the same.

function getSalt() {
    var random = new SecureRandom();
    var salt1 = new Array(32);
    random.nextBytes(salt1);
    return salt1;

}

Error logged as below.

java.util.concurrent.ExecutionException: javax.script.ScriptException: ReferenceError: "SecureRandom" is not defined.

Also, rhino js engine does not allow any import or load of external library. Is there a way we can generate secure random salts in Rhino?




Aucun commentaire:

Enregistrer un commentaire