Making my own encrytion program.....

McSkluvinMcSkluvin Regular
edited August 2011 in Tech & Games
I have a cipher I made that I think is pretty good considering my limited knowledge on cryptology, but right now I can only use it to encrypt stuff by hand. I was just wondering what types of coding I will need to learn to make this, keeping in mind that this is just for fun, not for serious encryption....

An example of how the cipher works is this: If "a" is in 1st, 4th, or 7th position, a=11, if "a" is in the 2nd, 5th, or 8th position, a=34, and it goes like that until it gets to the 9th position, then starts over at 1. I hope that makes sense.... Also, I treat the spaces between words as a character, making it harder to decrypt, hopefully......

Edit: Maybe this example will explain it better:

Let's take these words: "Aardvark poop". This is what they look like when encrypted with my "Rotary code" cipher: "112814217016355866331825". Since I used random two digits when I created my cipher, the enciphered text looks like nonsense, but let me break it down. Since the first "A" in "aardvark" is in the first position, it becomes "11", and since the second "a" is in second position, it becomes "28", and so on. This continues until you reach the character in the 9th position, which happens to be a space, which becomes "66". Then it starts over, with the first "p" in "poop" being in the first position, it becomes "33". The "OO" is treated as one character to make it harder to decipher, and since it's in the second position, it becomes "18".

Hopefully that explains how my cipher works without adding too much confusion, and I ask again: What kind of coding will I need to learn to make this simple cipher into a usable program?

Comments

  • edited July 2011
    Where the hell were you before pearl harbor?
  • McSkluvinMcSkluvin Regular
    edited July 2011
    Where the hell were you before pearl harbor?

    Umm....... what? :confused:
  • edited July 2011
    Yeah, playing dumb are we Jap boy?! I'm on to you.
  • McSkluvinMcSkluvin Regular
    edited July 2011
    Anyone, anyone?? :(
  • SlartibartfastSlartibartfast Global Moderator -__-
    edited July 2011
    http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html

    you'll probably make heavy use of charAt

    Another way to do this is with arrays, each character being an element.

    What rule are you following to get the numbers 11 for 1st 4th and 7th and 34 for 2nd 5th and 8th?
  • McSkluvinMcSkluvin Regular
    edited July 2011
    http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html

    you'll probably make heavy use of charAt

    Another way to do this is with arrays, each character being an element.

    What rule are you following to get the numbers 11 for 1st 4th and 7th and 34 for 2nd 5th and 8th?

    Thanks, I'll check that out. The numbers I used to replace each character are random ones I selected, so it's not really following a rule.
  • banditobandito Semo-Regulars
    edited August 2011
    For implementing this stuff I tend to use Perl, but you don't want to go using Perl until you've decoded its mysteries...
    I suggest you learn Python, because of how simple it is to write and read. Plus, it's a fantastic starter language- I assume you'll want to move on to something more advanced eventually, yes? However, just about any (decent) programming language ill do you fine.

    Perl is fun for simple ciphers because it has them powerful regular expressions. Python also has these, but they are mostly borrowed from Perl's. :P
    I really do suggest you use Python.
    Perl can be made unreadable, especially when trying to make a program as short as possible. Example: The RSA algorithm in 3 lines of Perl. This piece of code was infamous in the nineties, because at the time it was illegal to export strong encryption algorithms, and someone decided to put it on a t-shirt to make a statement. Some people actually have tattoos. Here it is (Warning: Line noise!):

    !/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
    $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
    lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

    For a complex algorithm like RSA, 3 lines is really an accomplishment.

    Since you're interested in cryptography, you should take a look at Vernam ciphers and the One-Time Pad if you haven't already. The latter is theoretically unbreakable mathematically, and also in practice so long as both copies of the pad are kept secure and no portion of the pad is ever reused for encryption.
  • DfgDfg Admin
    edited August 2011
    bandito wrote: »
    For implementing this stuff I tend to use Perl, but you don't want to go using Perl until you've decoded its mysteries...
    I suggest you learn Python, because of how simple it is to write and read. Plus, it's a fantastic starter language- I assume you'll want to move on to something more advanced eventually, yes? However, just about any (decent) programming language ill do you fine.

    Perl is fun for simple ciphers because it has them powerful regular expressions. Python also has these, but they are mostly borrowed from Perl's. :P
    I really do suggest you use Python.
    Perl can be made unreadable, especially when trying to make a program as short as possible. Example: The RSA algorithm in 3 lines of Perl. This piece of code was infamous in the nineties, because at the time it was illegal to export strong encryption algorithms, and someone decided to put it on a t-shirt to make a statement. Some people actually have tattoos. Here it is (Warning: Line noise!):

    !/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
    $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
    lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)


    For a complex algorithm like RSA, 3 lines is really an accomplishment.

    Since you're interested in cryptography, you should take a look at Vernam ciphers and the One-Time Pad if you haven't already. The latter is theoretically unbreakable mathematically, and also in practice so long as both copies of the pad are kept secure and no portion of the pad is ever reused for encryption.

    Holy fuck, 3 lines. I could never do that!
  • SlartibartfastSlartibartfast Global Moderator -__-
    edited August 2011
    Forget 3 lines, i'm just amazed that anyone can manage to understand perl ;):p
  • McSkluvinMcSkluvin Regular
    edited August 2011
    Thanks bandito, and I guess I should learn Python then, right after I finish learning JavaScript......
  • McSkluvinMcSkluvin Regular
    edited August 2011
    Write up a spec and I can give you some example code?

    Meh that would take the fun out of making it myself, I want to figure it out on my own, I just needed a push in the right direction.
  • edited August 2011
    Actually, example code can be pretty helpful without giving away too much. Looking through someone else's code can give you an idea of how things work, so I think you'd benefit from it :D
  • McSkluvinMcSkluvin Regular
    edited August 2011
    Okay then, but what exactly does he mean by write up a spec? :o

    Edit: I'm still not sure what he means, but maybe this will work:

    If "a" is in 1st, 4th, or 7th position, "a"=11. If "a" is in 2nd, 5th, or 8th position, "a"=28. If "a" is in 3rd, 6th, or 9th position, "a"=16. If "b" is in 1st, 4th, or 7th position, "b"=26. If "b" is in 2nd, 5th, or 8th position, "b"=35. If "b" is in 3rd, 6th, or 9th position, "b"=38. If "c" is in 1st, 4th, or 7th position, "c"=32. If "c" is in 2nd, 5th, or 8th position, "c"=81. If "c" is in 3rd, 6th, or 9th position, "c"=58.

    So using that, if we take "abccba", it becomes "113558323516".

    Hopefully that makes sense....
  • McSkluvinMcSkluvin Regular
    edited August 2011
    Cool, thanks man. :D:thumbsup:

    Like I said, I want to finish learning Javascript for now, but after I'm done I will work on my program.
Sign In or Register to comment.