| 03-31-2004, 02:38 AM | #1 |
What's a good way to scramble the digits of a 12 character code? [all numbers] The rest is done. |
| 03-31-2004, 10:36 AM | #2 |
Its purely to your own liking. out of my head, why dont you scramble the letters by fours (1st letter, then 4th , 8th, 12th, THEN 2nd, 6th, 10th... i hope you get the point). Then scramble the letters by threes in the same way. Then reverse it. Id like to see someone else break THAT ^_^ |
| 03-31-2004, 06:50 PM | #3 |
That is in fact very easy to break with... ah... I'd give it 5 codes. I think I'm gonna do something else, though. |
| 03-31-2004, 10:36 PM | #4 |
The best method is to generate a permutation of the numbers from 1 to 12 ie: 5, 7, 1, 12, 11, 8, 4, 9, 2, 10, 6, 3 Then you take pairs swap #5 with #7 swap #1 with #12 swap #11 with #8 etc etc This can be undone by doing exactly the same thing again, you just need a reliable way to generate the same permutation of numbers (and the more obscure the method used, the harder it is crack) |
| 03-31-2004, 10:44 PM | #5 |
<Yes, yes, I know.> |
| 04-01-2004, 02:44 AM | #6 |
So you have 12 digits And you want to use some reversible process that changes each digit so that the new code bears no resemblence to the old code? |
| 04-01-2004, 04:28 AM | #7 |
11 digits are code, 1 is the 'key'. There are three levels of encryption. Unmodified Code, Modified Code, Key-Modified Code. I'm looking for some things to do for the modified code and key-modified code. Yes, 12 digits, 0-9. |
| 04-01-2004, 05:06 AM | #8 |
Great, I've done an encryption course and I didn't sleep through all the lectures and I didn't forget all of it, so I still have a clue or two on how to encrypt stuff. The basic idea is to generate a random string of digits from the key, makes sense right? So you take the key and use it for the seed in a random number generator (RNG), and you get 12 numbers (between 0 and 9) from the RNG. A simple RNG works simply like this: x = a * x(-1) + c mod m a, c and m should be prime numbers (and fairly large ones). In warcraft 3, it looks like this: Code:
Set random = (((random x 1559) + 50513) mod 81817) So now everytime you run the above action, you get a new random number. And if you start it with the same seed, you get the same sequence of numbers. So now you can generate the 12 (or 11) new digits using (random mod 10), i'll call this the random pad. Now just add each digit from the code to the digit from the random pad, modulo 10. To reverse, generate the same sequence of numbers and use subtraction instead of addition (still modulo 10). Code:
4 0 0 7 1 3 9 8 0 1 6 The Original password + 2 1 9 6 7 2 8 5 2 6 1 The random pad = 6 1 9 3 8 5 7 3 2 7 7 The password, encrypted (bears no resemblence to original password) - 2 1 9 6 7 2 8 5 2 6 1 = 4 0 0 7 1 3 9 8 0 1 6 Back to the original password This RNG method is very powerful, and you can use multiple passes with different keys (for example, if this was for per-player, you could use the players name as the basis for the seed to the RNG). |
| 04-01-2004, 11:18 AM | #9 |
And what about when the code is something like 9 9 9 9 9 9 - 9 9 9 9 9 9 |
| 04-01-2004, 01:13 PM | #10 |
use the same idea as Grater...only give the digits a value based on their placement..and use that in the random generation code. That should fix your problem. |
| 04-01-2004, 10:32 PM | #11 | |
Quote:
When you add a random number to another number, you get what is effectively a random number. If the original code was all nines, the new code would be exactly the random pad, which I guess would be bad if players can choose the original code, one of the dangers of not explaining what the hell the code is for >.< What I do with my hero save/load code system is this: First it uses binary, not decimal. So i'm working on 1's and 0's instead of 0-9. (as the final stage it's converted into a 32 letter alphabet) 1) A 9 bit CRC check is appended to the end of the code (only 1 in 512 random codes will be valid) 2) A pairwise scramble is used, swapping each bit with another random bit. The key/seed used is a hash of the player name. 3) A random pad is used, XOR'ing every bit with a random bit. The key/seed is another hash of the player name. By this point the original data is totally masked, changing something simple, like swapping one item into another slot, will change about 10 letters in the encyrpted code (this is the HUGE benefit of using binary) 4) A 6 bit random number (between 0 and 63) is appended to the end, and used as the key/seed for another random pad. Now the same hero doesn't generate the same code [everytime] anymore. Ofcourse being a hero system the player cannot possibly ever create an all 0's or all 1's code, which makes it even harder to crack. Even then the bitwise scramble swap would totally confuse anyone trying to crack it, how do you tell which 1 or 0 went where? --- But for a non-binary system too much detail would remain... I think I can come up with another method: Split the 12 digit code in half Code:
A B 9 9 9 9 9 9 - 9 9 9 9 9 9 Use this random number as a seed to the RNG, and generate a 6 digit random pad. Add this random pad to B. Now repeat the above, using the newly scrambled B to generate a seed to scramble A. This will scramble both halves in a delightful way, and doesn't require any additional key, because it doesn't need a key it makes a good final step. |
