At 09:52 AM 11/2/00 +0800, Kenix wrote:
hi all, suppose we have two numbers, one is serial added(about 8~10 digits), another is a random number(about 7~12 digits), then how can i generate a 5 digits number depends on both of them? there shouldn't have any key so i can verify the 5-digit number later just use the pervious two numbers, i know the security is completely depends on the method that how to generate this 5-digit number. any good method you all can hint me? any good random number generator?
This is called hashing. There are lots of ways to do this. If you need cryptographic strength, use a cryptographically strong hash function like SHA1 and keep 5 digits of output. If you don't need cryptographic strength, use a CRC code (Cyclic Redundancy Check). There are lots of books out there with theory or examples about CRCs and cryptographic hashes. The basic differences are how easy it is to predict differences in the input given different outputs - in cryptography you care about this being hard, while for regular applications you just care that different inputs usually give different outputs so everything's distributed evenly. Thanks! Bill Bill Stewart, bill.stewart@pobox.com PGP Fingerprint D454 E202 CBC8 40BF 3C85 B884 0ABE 4639