5 ms·
building your own crypto is so simple a 5 year old can do it, just roll a dice, and write down the numbers, those numbers are the key. Then convert the text to
by z3t4 2y ago
building your own crypto is so simple a 5 year old can do it, just roll a dice, and write down the numbers, those numbers are the key. Then convert the text to numbers, and for each letter add the corresponding key number, and the sum will be the encrypted text. To decrypt you subtract the number with the corresponding number on the key.
The problem is that modern crypto is so complicated one will easily make an error implementing it.
- smitelli 2y agoThat works if your key is long as heck, or the message is short as heck. Still, a useful way to quietly entertain (some) kids for a little while.
- olddustytrail 2y agoIn that scheme -5 is always A and there are only 6 options for any particular letter, so you can do a slightly more complicated frequency analysis. Sounds like it might be good for kids learning how to break crypto?
- BenjiWiebe 2y agoAdd to encrypt, so 32 is always Z.
- z3t4 2y agoIt's unbreakable, google for "one time pad" encryption. The problem with cracking it is that if you just change one letter in an English word it becomes another English word. Here i have encrypted "hackernews" with the following key 2,3,1,6,2,1,2,2,1,3 Good luck cracking it without the key: JDDQGSPGXV
- loup-vaillant 2y agoAs was said above, don't just add a number from 1 to 6. You want your ciphertext to be indistinguishable from random, so in this case (assuming only letters and no punctuation nor space), you need to add a number from 0 to 26. And you need a uniform distribution, or again, statistical analysis will screw you. Now one does not simply generate a uniform random distribution from a d6. You can't throw the die 5 times and add the results for instance. First, you'll get a number between 5 and 30. Not only the range falls short one letter (25 possibilities instead of 26), what you get is a binomial distribution, heavily skewed towards the middle numbers (5 and 30 are very improbable in comparison). My recommendation here would be to throw the die once, subtract 1, multiply by 6, throw it a second time, add it, subtract 1. This will give you a uniform distribution between 0 and 35 (assuming your die is perfectly fair, which, spoiler alert, it isn't). Think of it of a 2-digit base 6 number. Assign a number to each letter of the alphabet (and now you can even support spaces & punctuations, or numbers), add (modulo 35) the result of your die throw, do not translate the result to an encoding with less than 36 symbols, and now you have a proper one time pad. One thing that's crucial when attempting anything cryptographic: make sure you've got the maths down. Ideally you should be able to construct a rigorous (even machine verified) proof that your stuff works as intended. For the one time pad it's relatively easy. But you need to do it, that's how you'll notice that if you encrypt "aaaaaaaaa" your result will only yield letters between B and G, which you'll agree doesn't hide your plaintext nearly as well as you intended.