## Encryption Programming

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

### Encryption Programming

Hi HTS, I'm here with another few noob-ish questions.
Today I'm my biology 2 class, I was thinking about encryption and why more people don't use there own little codes for sensitive information. Well, it didn't take long for my ADHD to wonder off during the boring lecture on DNA replication.
My school was put on a yellow code (meaning we weren't allowed out of the class room, apparently someone was shot near our school) snapping me out of my day dream. Anyway, saw protein combos on the board, blah blah blah, came up with this

The key= a, a-f ---- t, g-l ----- g m-r----- c, s-x

t3, g1t3a3t2a1a5t6 c5a1g3a4, t2a5a5a4 t2a5t6f4 programming this.

Anyway, my dilemma is that I have no clue how to program a quick decryption for this. I know its not a strong code or anything, this is way more just a learning experience. So if anyone has any suggestions on even what language to use or anything, it'd be very helpful.
Werevamp999
New User

Posts: 12
Joined: Fri Oct 15, 2010 7:05 am
Blog: View Blog (0)

### Re: Encryption Programming

Werevamp999 wrote:The key= a, a-f ---- t, g-l ----- g m-r----- c, s-x

I'm trying to help you and I get your key, but what do the numbers in the encrypted String mean? Also, there's an "f" in the encrypted String and I don't think that's on purpose, because all the other alphabetical chars in it are a, t, c, or g.

Also, if you're substituting 6 or 7 different letters all for the same letter, there are going to be a lot of collisions in terms of how many inputs generate the same encrypted String (unless that's why you have the numbers?). Not one hundred percent sure about this but I think any encryption that is easily susceptible to multiple inputs generating the same encrypted String is vulnerable to a birthday attack.

sandbox wrote:Using RetardFish, I have determined it is retardese for "thanks". It translates literally to "I enjoy phalluses in naughty areas".
Defective Flamesuit
New User

Posts: 32
Joined: Fri Sep 17, 2010 10:31 pm
Blog: View Blog (0)

### Re: Encryption Programming

A bit off topic but biology isn't boring! One of the greatest talks I've seen: Programming DNA

edit, better version: http://dewy.fem.tu-ilmenau.de/CCC/24C3/mp4/24c3-2329-en-change_me-COMPATIBLE.mp4

tgoe
Contributor

Posts: 527
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)

### Re: Encryption Programming

Also, if you're substituting 6 or 7 different letters all for the same letter

Please excuse me, I am confused as to where I am substituting two different terms for the same letter?
I will go over the code when I get home, as I am currently accessing this from a place where I would rather not write anything down.
Werevamp999
New User

Posts: 12
Joined: Fri Oct 15, 2010 7:05 am
Blog: View Blog (0)

### Re: Encryption Programming

Ah, I finally understand! You should have made this way clearer in your original post. He's using the numbers after each a,t,g, or c to indicate which letter it is.

So for example, because t spans g through l (according to his key), typing t5 would lead to: g, h, i, j, k, l. I didn't translate his whole example encrypted String but I know it starts out with "I, michael".

So now I can comment on it. Cryptographically, it sucks. But you knew that, saying you didn't care about security, and just wanted to see how to write an algorithm to decode it. So I'm going to do that, because I'm nice and I'm bored. I code in java.

Code: Select all
`import java.util.Scanner;public class DNAencryption {    public static void main(String[] args) {        String code = "";        String cleartext = "";        String[] a = {"a","b","c","d","e","f",};        String[] t = {"g","h","i","j","k","l",};        String[] g = {"m","n","o","p","q","r",};        String[] c = {"s","t","u","v","w","x","y","z"};                Scanner input = new Scanner(System.in);        System.out.println("Input a string to decrypt.");        code = input.nextLine();                for(int i=0; i<code.length();) {            if(code.charAt(i)=='a') {                cleartext += a[Character.getNumericValue(code.charAt(i+1))-1];                i+=2;            }            else if(code.charAt(i)=='t') {                cleartext += t[Character.getNumericValue(code.charAt(i+1))-1];                i+=2;            }            else if(code.charAt(i)=='g') {                cleartext += g[Character.getNumericValue(code.charAt(i+1))-1];                i+=2;            }            else if(code.charAt(i)=='c') {                cleartext += c[Character.getNumericValue(code.charAt(i+1))-1];                i+=2;            }            else {                cleartext += code.charAt(i);                i++;            }        }                System.out.println(cleartext);    }}`

There's definitely a more elegant solution than creating arrays for a, t, g, and c at the top (like incrementing ASCII values or something), but this will decrypt it. Also note there are two errors in the sample you posted: the second to last character "f" should be "g", and the first character of the third word should be "g", not "t". When those are fixed the sample code given will output: "i, michael waod, need help". I'll explain the code in another post sometime soon if you want.
sandbox wrote:Using RetardFish, I have determined it is retardese for "thanks". It translates literally to "I enjoy phalluses in naughty areas".
Defective Flamesuit
New User

Posts: 32
Joined: Fri Sep 17, 2010 10:31 pm
Blog: View Blog (0)

### Re: Encryption Programming

Bravo!
Well done! Thank you so much for helping me with this. While I was waiting for someone to help me, I was brushing up on Python and started to write something to decode it with that. I don't have the source code at my disposal right now, but basically I wrote it out to where if, for instance, a1 = ['a'] . The bad thing about it is I have to seperate the letters. I'm working on it though, and it has been a fun project, even as simple as it is once you get down to it.

-- Tue Oct 26, 2010 1:19 pm --

Defective flamesuit -
I am currently in the process of programming a decryption but am having problems with the code.
Code: Select all
`aa = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6']tt = ['t1', 't2', 't3', 't4', 't5', 't6']cc = ['c1', 'c2', 'c3', 'c4', 'c5', 'c6']gg = ['c1', 'c2', 'c3', 'c4', 'c5', 'c6']database = aa, tt, cc, gggreece = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 't', 'u', 'v', 'w', 'x', 'y', 'z']a1 = 'a'a2 = 'b'a3 = 'c'a4 = 'd'a5 = 'e'a6 = 'f't1 = 'g't2 = 'h't3 = 'i't4 = 'j't5 = 'k't6 = 'l'c1 = `

I've been doing it the long way, do you mind me PMing you to ask for help? I've looked up on google but can't seem to find the answer

-- Tue Oct 26, 2010 2:40 pm --

Oops, didn't mean to cut off the code.
Code: Select all
`aa = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6']tt = ['t1', 't2', 't3', 't4', 't5', 't6']cc = ['c1', 'c2', 'c3', 'c4', 'c5', 'c6']gg = ['g1', 'g2', 'g3', 'g4', 'g5', 'g6']database = aa, tt, cc, gggreece = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 't', 'u', 'v', 'w', 'x', 'y', 'z']a1 = 'a'a2 = 'b'a3 = 'c'a4 = 'd'a5 = 'e'a6 = 'f't1 = 'g't2 = 'h't3 = 'i't4 = 'j't5 = 'k't6 = 'l'c1 = 'm'c2 = 'n'c3 = 'o'c4 = 'p'c5 = 'q'c6 = 'r'g1 = 's'g2 = 't'g3 = 'u'g4 = 'v'g5 = 'w'g6 = 'x'`
Werevamp999
New User

Posts: 12
Joined: Fri Oct 15, 2010 7:05 am
Blog: View Blog (0)