You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
export function randomChar(prng) {
let rand = Math.floor(prng() * ENCODING_LEN);
if (rand === ENCODING_LEN) {
rand = ENCODING_LEN - 1;
}
return ENCODING.charAt(rand);
}
I believe this biases the final character in the ENCODING array, which has two different random values it can be created from.
I believe what you want is to do is select a new random number in this case, since while it is difficult to get this value (a 1 in 256 chance) that is still an increase in bias.
While the increase is small, it feels like using a strong prng only to add unnecessary bias should be addressed.
The text was updated successfully, but these errors were encountered:
From the code:
I believe this biases the final character in the ENCODING array, which has two different random values it can be created from.
I believe what you want is to do is select a new random number in this case, since while it is difficult to get this value (a 1 in 256 chance) that is still an increase in bias.
While the increase is small, it feels like using a strong prng only to add unnecessary bias should be addressed.
The text was updated successfully, but these errors were encountered: