Page 1 of 2
Random Numbers
Posted: Sat Dec 17, 2016 7:05 pm
by Dan Honeycutt
Hi All,
If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.
Best
Dan H.
Re: Random Numbers
Posted: Sat Dec 17, 2016 10:02 pm
by mar
Dan Honeycutt wrote:Hi All,
If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.
Best
Dan H.
Here's mine, proven to be good (real world scenarios):
Code: Select all
ULong keys[2];
inline ULong Rotate(ULong v, Byte s) {
return (v >> s) | (v << (64-s));
}
// generate next 64-bit random number
inline ULong Next64()
{
ULong tmp = keys[0];
keys[0] += Rotate(keys[1] ^ 0xc5462216u ^ ((ULong)0xcf14f4ebu<<32), 1);
return keys[1] += Rotate(tmp ^ 0x75ecfc58u ^ ((ULong)0x9576080cu<<32), 9);
}
where ULong = uint64_t
IV is two 64-bit numbers (keys) so seed with whatever you want.
If your compiler can fold rotations (last time I tried with clang it couldn't), it can generate ~1 billion 64-bit PRN per second on my several years old stock i7 quad (single core).
public domain.
Of course it's not crypto-secure so I'm not sure what you want to accomplish. Generates sequence to xor input data with? Might work as a naive encryption.
Re: Random Numbers
Posted: Sun Dec 18, 2016 3:10 am
by Milos
Dan Honeycutt wrote:Hi All,
If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.
https://en.wikipedia.org/wiki/Mersenne_Twister
Re: Random Numbers
Posted: Sun Dec 18, 2016 4:05 am
by Dann Corbit
Re: Random Numbers
Posted: Sun Dec 18, 2016 6:10 am
by Dan Honeycutt
mar wrote:Of course it's not crypto-secure so I'm not sure what you want to accomplish. Generates sequence to xor input data with? Might work as a naive encryption.
What I'm working on is a very simple text editor with a password feature to use to store the many passwords you end up with if you are active on the internet. I'm an encryption noob, what advantage would a crypto-secure RNG give, just harder to decrypt?
Best
Dan H.
Re: Random Numbers
Posted: Sun Dec 18, 2016 6:14 am
by Dan Honeycutt
Milos wrote:Dan Honeycutt wrote:Hi All,
If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.
https://en.wikipedia.org/wiki/Mersenne_Twister
I've read that Kiss is something of an improvement over the Mersenne Twister but I certainly don't know enough to attest one way or the other.
Best
Dan H.
Re: Random Numbers
Posted: Sun Dec 18, 2016 6:26 am
by Dan Honeycutt
Thanks, Dann. I'm still trying to understand if I really need a crypto-secure RNG but if I do your second link looks like a good candidate.
Best
Dan H.
Re: Random Numbers
Posted: Sun Dec 18, 2016 8:51 am
by Dann Corbit
Dan Honeycutt wrote:mar wrote:Of course it's not crypto-secure so I'm not sure what you want to accomplish. Generates sequence to xor input data with? Might work as a naive encryption.
What I'm working on is a very simple text editor with a password feature to use to store the many passwords you end up with if you are active on the internet. I'm an encryption noob, what advantage would a crypto-secure RNG give, just harder to decrypt?
Best
Dan H.
If you want to handle passwords, you NEED a crypto secure method.
Especially since users tend to reuse passwords.
Re: Random Numbers
Posted: Sun Dec 18, 2016 9:27 am
by kbhearn
When it comes to cryptography there's so many ways to mess it up that you really shouldn't roll your own anyways for anything other than educational purposes - take an existing crypto library, use it as intended. Even your own implementation of an accepted protocol is risky (your implementation may 'work' while not being secure against subtle attacks) - heavily used crypto libraries you at least have the peace of mind that many people are looking for and fixing these vulnerabilities.
Re: Random Numbers
Posted: Sun Dec 18, 2016 9:35 am
by Lyudmil Tsvetkov
one more thread, when one wonders, especially when posted by a mod, whether it belongs strictly here.
in any case, I see nothing related to computer chess: the use is not intended to tackle building a chess engine and, even if it were so, still the rigth forum would be the programming section.
on the other hand, I find Harvey's London chess classic thread quite acceptable, as people are using engine output to decide on a position.