[erlang-questions] crypto:rand_bytes/3
Emad El-Haraty
elharaty@REDACTED
Sun Mar 2 08:10:41 CET 2008
Hi,
Browsing through crypto.erl, I noticed the exported but undocumented
function crypto:rand_bytes/3.
The three parameters it takes are: Bytes, Topmask, Bottommask
Bytes is the number of random bytes you would like generated
Topmask is the value that will be used in performing a bitwise or on
the final byte (of the bytes generated)
Bottommask is the value the will be used in performing a bitwise or on
the first byte.
RAND_pseudo_bytes(bin->orig_bytes,rlen);
or_mask = ((unsigned char*)buf)[4];
bin->orig_bytes[rlen-1] |= or_mask; /* topmask */
or_mask = ((unsigned char*)buf)[5];
bin->orig_bytes[0] |= or_mask; /* bottommask */
Just out of curiosity, what use would someone have for this ability to
mask only the first or final bytes of a randomly generated set of
bytes?
--
Emad El-Haraty
"I sure wish there was a way to transform c source into some sort of
machine code"
More information about the erlang-questions
mailing list