jsrsasign icon indicating copy to clipboard operation
jsrsasign copied to clipboard

Seeding the PRNG

Open metalicworker opened this issue 12 years ago • 1 comments

I needed to seed the PRNG with a specific value. After some poking around I found that it can be done like so:

function hex2Array(hex) { var arr = new Array(); for (var i = 0; i < hex.length; i += 2) arr[i/2] = parseInt(hex.substr(i, 2), 16); return arr; }

var seedByteArray = hex2Array(seedHexStr);

//////////////// rng_state = prng_newstate(); rng_state.init(seedByteArray); ///////////////

It might be nice to add these last two lines into a "seed" function of the SecureRandom class in the future

metalicworker avatar Nov 20 '13 10:11 metalicworker

@kjur Any chance that this will be implemented?

Ruffio avatar Jul 25 '17 07:07 Ruffio