Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeding the PRNG #42

Open
sbheinric opened this issue Nov 20, 2013 · 1 comment
Open

Seeding the PRNG #42

sbheinric opened this issue Nov 20, 2013 · 1 comment

Comments

@sbheinric
Copy link

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

@Ruffio
Copy link

Ruffio commented Jul 25, 2017

@kjur Any chance that this will be implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants