
|
84783 packages online
|
|
 |
|
dev/c/MD5Random.lha |
|
No screenshot available
|
Short: | MD5-based Random Number Generator (PPC+68k) |
Author: | Rich Skrenta, Andreas R. Kleinert (port and sample program) |
Uploader: | info ar-kleinert de |
Type: | dev/c |
Architecture: | m68k-amigaos,ppc-powerup |
Date: | 2000-06-01 |
Download: | dev/c/MD5Random.lha - View contents | Readme: | dev/c/MD5Random.readme |
Downloads: | 652 |
|
*************************************************************************
After becoming frustrated with the lack of a standalone, portable,
decent random number generator, I decided to make one based on a
cryptographic one-way hash function. I chose MD5 since it is fast
and free source was readily available. More cryptographically
secure hash functions are available (e.g. SHA-1), but for the
purposes of a rand/random/erand48 replacement, MD5 should be more
than sufficient.
MD5 takes an arbitrary amount of input and yields a 16 byte hash.
This RNG continually MD5's a 16 byte digest, and uses the bottom N
bits as the random number yielded, where N is just large enough to
include the largest random number desired.
To yield a random number between 0 and r:
create mask which has enough bits to include all of r
(for example, if r is 100, mask would be 0x7F)
do {
digest = MD5(digest)
number = digest & mask
} while (number > r)
The digest should be loaded and saved to a disk file between
invocations of a program using the RNG.
Random functions appear after the included MD5 code.
Send comments to: skrenta@pbm.com (Rich Skrenta)
*************************************************************************
The Amiga 68k/PPC version comes with both, makefiles for 68k and PPC,
and test programs for both CPUs.
A few changes had to be made for the Amiga port (#ifdef AMIGA) - and
since this random number generator has a "brain", the most important
change perhaps was, that the location of this brain now is "s:randseed".
In case you want to run multiple copies of it, you'll perhaps like
to choose a different (process-dependent) name. You also could fetch
the "digest" from somewhere else (i.e. using a conventional random
number generator).
--
ARK, 30/May/2000
|
Contents of dev/c/MD5Random.lha
PERMSSN UID GID PACKED SIZE RATIO CRC STAMP NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic] 254 459 55.3% -lh5- eec6 May 30 2000 MD5Random/main.c
[generic] 1021 2082 49.0% -lh5- cd75 May 30 2000 MD5Random/MD5Random.readme
[generic] 8982 13836 64.9% -lh5- 7b94 May 30 2000 MD5Random/random
[generic] 3577 9932 36.0% -lh5- b120 May 30 2000 MD5Random/random.c
[generic] 16782 34830 48.2% -lh5- abfb May 30 2000 MD5Random/random.elf
[generic] 383 831 46.1% -lh5- aabf May 30 2000 MD5Random/random.info
[generic] 155 233 66.5% -lh5- 3ca8 May 30 2000 MD5Random/SCOPTIONS
[generic] 118 234 50.4% -lh5- fb12 May 30 2000 MD5Random/smakefile
[generic] 103 200 51.5% -lh5- 5299 May 30 2000 MD5Random/smakefile68k
---------- ----------- ------- ------- ------ ---------- ------------ -------------
Total 9 files 31375 62637 50.1% May 31 2000
|
|
|
 |
Page generated in 0.02 seconds |
Aminet © 1992-2024 Urban
Müller and the Aminet team.
Aminet contact address: <aminet aminet net> |