0x10f on Nostr: When making a password generator a while ago, I noticed this algorithm doesn't give ...
When making a password generator a while ago, I noticed this algorithm doesn't give the correct distribution:
1) start the password with the characters it has to have (e.g. one digit)
2) fill the rest of the password randomly according to the requirements (e.g. digits and letters)
3) shuffle the password.
For example, if you need to generate a two-character password using only A and 1, with at least one 1, these should be equiprobable: A1, 1A, 11. But if you start with 1A or 11 and shuffle it, you'll end up with 11 half the time.
Published at
2024-07-25 22:51:30Event JSON
{
"id": "93cf627a1e1d71d26d162462d461782b2b5c5d50e38bfdd5ccf0bb4915fae181",
"pubkey": "584b33223e8ee56eec67a8307121493eb3c5400258ff3b295789e13b9a1527be",
"created_at": 1721947890,
"kind": 1,
"tags": [
[
"p",
"597022b3c20de92675ad38e490aa9b80cda1beed34e044ecc73d8e00c42c63eb"
],
[
"e",
"ffea9d8e1fb7e7bf38efe3846b8b2f7a4bea1d0af5afcce6e6855f457b5bae1e",
"",
"root"
],
[
"proxy",
"https://tech.lgbt/@0x10f/112849576941263832",
"web"
],
[
"proxy",
"https://tech.lgbt/users/0x10f/statuses/112849576941263832",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://tech.lgbt/users/0x10f/statuses/112849576941263832",
"pink.momostr"
],
[
"-"
]
],
"content": "When making a password generator a while ago, I noticed this algorithm doesn't give the correct distribution:\n1) start the password with the characters it has to have (e.g. one digit)\n2) fill the rest of the password randomly according to the requirements (e.g. digits and letters)\n3) shuffle the password.\n\nFor example, if you need to generate a two-character password using only A and 1, with at least one 1, these should be equiprobable: A1, 1A, 11. But if you start with 1A or 11 and shuffle it, you'll end up with 11 half the time.",
"sig": "50c814a703e0bc3bc17f1efc7443c3546418e6e414b0fdbc536ce3175c92f3bb74c3deb83f21966fdce41ee32aa7414263f5fe54a5bc77ccee3d58fb5bf12009"
}