How can we generate Random Salt of 32 bytes in Rhino JS #1174
-
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.
Error logged as below.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This worked in my environment. var random = new java.security.SecureRandom();
var salt1 = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 32);
random.nextBytes(salt1);
salt1.join(); // -69,-43,62,15,-48,-78,-68,-10,-74,-108,-43,44,-43,-108,27,8,41,102,91,-64,-88,-81,107,-46,-99,24,-64,85,11,89,52,21 |
Beta Was this translation helpful? Give feedback.
This worked in my environment.