A simple combination lock, for cryptography.
Usage: You take the number, and use that to generate a key to encrypt/decrypt data. You can use this to make a safe, where users can safely store there files.
Keys (should be randomly generated)
int128 combinations[NUM];int256 modkey;
NUM is the number of combinations in the key, more is better, but harder to use.
Complexity is (If you have all of the keys, it is much greater otherwise) KEYS^NUM. So, if you have 18 keys (0-9, A-F, # and *), and 12 digits in the combination, there are 1,156,831,381,426,176 combinations. That is if you have the key.
Now, if you don't know the keys, you basically have to check 2^256 different mods, as well as (2^128)^Num
Leaving (2^128)^num * 2^256
Which is massive.
Very massive.
It is about
279095111627852376407822673918065072905887935345660252615989519488029661278604994789701101367875859521849524793382568057369148405837577299984720398976429790087982805274893437406788716103454867635208144157749912668657006085226160261808841484862703257771979713923863820038729637520989894984676774385364934677289947762340313157123529922421738738162392233756507666339799675257002539356619747080176786496732679854783185583233878234270370065954615221443190595445898747930123678952192875629172092437548194134594886873249778512829119416327938768896
Now, you are not going to check that many keys anytime soon.
Code:
int256 combination;for x = 0 to NUMcombination += INPUTDIGIT * combinations[x];combination %= modkeynext x// Combination is now your key.
It is simple, yet quite effective.
I'm probably going to write an application to run safes like these. Which doesn't store the actual values with itself, so you could say email someone a safe, keep the combination file inside a flashdisk, and know that nobody is ever going to get the combination. Especially if you have a very long combination. a 12 digit combination is fine, as it has about a quadrillion possible combinations. You could use a slightly longer key, and the number of combinations skyrockets.
:)
But of cource its limited by how bit modkey is.
The output number, has only modkey combinations, which means that at most, it will take modkey attempts.
But then again, modkey would be randomly generated, and basically guarenteed to be huge (and for those who don't have the keyfile, impossible to determine).
Its not like integer factorisation (see RSA), where at most you have to check sqrt(n), you have to check half of N on average.
Thats 2^255 or only about
57896044618658097711785492504343953926634992332820282019728792003956564819968
Which is also very very very massive.
If you have a long enough key, then you end up with the number of combinations being dwarfed by the number of posisble keys (modkey).
From,
Nice coder
[Edited by - Nice Coder on February 5, 2005 6:42:48 PM]