Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MD5 RNG

Posted on 2001-06-29
9
Medium Priority
?
1,138 Views
Last Modified: 2008-01-16
Hello,

Can anybody explain me how does the MD5 RNG method to generate random numbers work? I hear that it uses hash tables, but I don't know much about it.
I just want to know a simple explanation, I don't need any actual implementation.

Thanks
0
Comment
Question by:elito
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 400 total points
ID: 6237381
You can find article +source code in
http://www.pbm.com/dice/random.html
0
 

Author Comment

by:elito
ID: 6237424
Thanks for the link.
As I said I don't need source code. Could you explain me what are hash tables and how they're used to produce better random numbers?

cheers,
elito
0
 
LVL 22

Expert Comment

by:nietod
ID: 6237692
I am not familar with this algorithm.  But it appears to me that it does not use hash tables, but only a hash operation.

a hash operation is used to convert data, usually of a reasonably large size, like a string, to a smaller, seemingly random binary value (a number).   For example, to hash a string, you might add up the numerical values of all the ASCII characters in the string to produce a hash value, a single number.  to hash a 3d point, you might take the product of the 3 coordinates to produce a single number.   etc.     While the value produced by the hash operation appears to be random it is not.   Givien the same initial data you can repeat the process to produce the exact same hash value.  However the reverse is not true.  Ther is no way to take a hash value and deduce the original data.

Hash values are used in hash tables.   If you need to store data for rapid searching, you hash the data and then place it in a hash table at a position determined by its hash value.   If you latter need to find that item, you can produce a hash value for that item, then look it up in the table.   hash searches tend to be approximately constant complxity.  That is, no matter how many items are in the table, it always takes the same amount of time (which is very little) to find an item.  Other mechanisms, like binary trees (or other trees) tend to get slower as the number of items increase.    However they have features that hash tables don't.  Trees, sorted arrays, heaps can be iterated in order.  hash tables cannot.  Trees etc, can also be used to find near matches.  i.e search for "the" and find :"these".   hash table tables cann only be used for exact matches.      But they are perfect for example, for storing symbols a compiler finds in a program.  Whent he compile sees a symbol being used like "FileCount" it can search the hash table to see if the symbol was declared and what its type is etc.   This search only requires an exact match.


Anyways that code seems to be using a hash operation to develop pseudo-random data that is then used to generate the pseodo-random number.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6237782
this random generator uses MD5 digest.
Message digests are secure one-way hash functions (NOT hashtable) that take arbitrary-sized data and output a fixed-length hash value. This hash value truncate to your  random interval.
for producing better random numbers you could use some heuristic rules:
1. set any simple integer function f(i) = (i+25)^12+i*7542+...
2. generate MD5 digest for each i = 1000 ... 10000.
3. truncate digest for random interval

Do you want to know mathematics principles of crypto?? i know some russian articles for this.

Andrey
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6237797
change
2. generate MD5 digest for each f(i) (where i = 1000 ... 10000).

Andrey
0
 
LVL 22

Expert Comment

by:nietod
ID: 6237814
Do plynomials like that one in "1." work to produce decent results (numbers well deestributed over the range and with no discernable patern)?   My intuition would tell me no.
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6238009
your intuition ...
>> Message digests are SECURE ONE-WAY hash functions (NOT hashtable) that take arbitrary-sized data(may be any successive numbers) and output a fixed-length hash value...

hacker cannot to know the following random number, if he know all preceding random numbers (one condition : he don't know polynom; user could select any polynom every time).

best regards
Andrey
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6805688
elito,

These questions are still open and our records show you logged in recently. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days. Please note that the recommended minimum for an "Easy" question is 50 points.

http://experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20143225
http://experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20256254
http://experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20079951
http://experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20013179
http://experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20081494
http://experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20078523
http://experts-exchange.com/jsp/qShow.jsp?ta=xml&qid=20240193

EXPERTS: Please leave your thoughts on this question here.

Thanks,

Netminder
Community Support Moderator
Experts Exchange
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6822200
Force/accepted by

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question