How can we generate Random salt of 32 bytes in js script for FR IC?

How can we generate Random salt of 32 bytes in js script for FR IC?

Karan Nayyar

I wanted to generate a random salt of 32 bytes size. I know SecureRandom class can be used for the same. However,this is blacklisted in our dev tenant.Is there an API which can be used in js script to generate same?

2. RE: Generate random salt of 32 bytes in JS script for IC

Stephane Orluc

Posted 02-25-2022 07:57

hi @Karan Nayyar,

‚ÄčI never used this class in a script. For a PoC maybe you could just generate your salt manually. See below an example to generate a random number.

function createRandom() {
return 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[x]/g, function(c) {
var r = Math.random()*16|0;
var v = r;
return v.toString(16);
});
}


Stephane Orluc

3. RE: Generate random salt of 32 bytes in JS script for IC

Dom Reed

Posted 02-28-2022 08:19

Hi Karan

We have recently rolled out a change to allow access to org.forgerock.openam.shared.security.ThreadLocalSecureRandom . This class is a wrapper for java.security.SecureRandom and provides the following public static method:

public static byte[] nextBytes(int size)

Hope that helps!
Dom


Dom Reed