Tried My Hand At Encryption, Try To Break It

The fear of every surveillance society: citizens protecting their own privacy with strong cryptography

Tried My Hand At Encryption, Try To Break It

Post by demogorgon22 on Fri Jul 22, 2016 3:25 pm
([msg=92655]see Tried My Hand At Encryption, Try To Break It[/msg])

Alright, so first off I'm gonna have to say that I know better than to use my encryption for anything and to stick to the fancy expertly done methods.
Second off I'm gonna have to say that I don't know jack about cryptography. :P

So about a year ago I had an interesting idea and tried to prototype it. I ended up with a crappy method of encryption that required a key several thousands of characters long and tripled the length of whatever text was encrypted.
I decided to come back to it this week and changed a great deal of things, vastly improving it.
The current JS prototype can be found here. https://jsbin.com/piyizuh
I intend to finish the C++ version after ironing out the basic issues with the JS prototype.

http://pastebin.com/raw/Vh5BeghG Here you can find the source which I will be documenting below. It is very bad.

I would love to see someone try to break it. Anyone interested, try to decode this:
2m2B@s☻n+JJ!$Kp^I9t^mSu0EZUH9gDY"''}q◘Z•^zbXceVHy♥AV


Encrypting Text
When the encrypt button is pressed the letters and shorthand arrays are set to their default value, the letters and shorthand arrays are then shuffled based on the key by the shuffle function, the text in the input box is run through the encryption function, then the compression function, and then returned in the output box.

Shuffle(String):void
The shuffle function gets the ascii code number of each character in the string argument it is given and appends them to a string. This string is then looped through 400 times appending even more numbers to a larger string. These numbers are based on the ascii codes of the string argument, and the number of times the loop has been iterated through. It is then made sure that the new, large, string of numbers has a length divisible by two, append a "9" onto the end if it doesn't The large string is now run through a loop in such a way that the first and last characters in it are now the first and second, and the second first and second last are now the 3rd and fourth, continuing all the way through the string. This was needed due to the way the 400 time loop worked. The new, rearranged, large string is now made sure to have a length divisible by 4. If it does not, "89" is appended to the end. The large string of numbers is now looped through for its entire length at an interval of 4 and I'm really not sure how to explain what happens next at this point, look at the code. Basically, these numbers are used to rearrange the shorthand and letters arrays.

Encrypt(String):String
The string argument is looped through, and the position of each character in the letters array is appended to a string. When this finishes, the function returns the string of character positions. This means that a very small set of characters is supported. This could be resolved by first base64 encoding the string argument. The code for this is from a year ago and went under a lot of revision then so it's really ugly and I don't want to look at it. This function returns a string twice as long as the string it is given.

Compress(String):String
The code is short enough that I'm gonna just drop it here because its hard to explain and I did a poor job explaining similar code in the Shuffle section.
Code: Select all
function compress(nums){
var compressed="";
for(i=0;i<nums.length/2;i++){
compressed +=shorthand[Number(nums[i] + nums[nums.length-1-i])];
}
return compressed
}

Shorthand contains 100 unique characters.

Decrypting Text
When the decrypt button is pressed the letters and shorthand arrays are set to their default value, the shuffle function is called with the key from the key box, the input text is run through the decompress function, run through decryption, and then outputted below, ideally decoded if the key is correct. That was one hell of a run on.

Decompress(String):String
The index of each character of the inputed string in the shorthand array is found. The index is made to be 2 digits if less than 10 by preceding with a 0. The first digit of the two is appended to the part1 string, and the second digit is appended to the part two string. Part 2 string is reversed. Part 1 string is then appended to a final string, followed by the newly reversed part 2 string. This is then returned.

Decrypt(String):String
The inputed string is looped through taking two of its characters at a time, converting them to ints, and appending the value of the letters array they index to a string, ultimately returning the decrypted string when finished.

Final Thoughts
I cannot possibly fathom how this could be breakable other than by brute force. I'm sure it is though because I know next to nothing about cryptography. I don't even know if I used the right words for stuff. I would be very interested in seeing how the hell someone cracked it. I also would be happy with general thoughts, or ideas as to how to improve it. (Other than just scrap it and use the real stuff, although let's be real, that's the way to go. :P)
demogorgon22
New User
New User
 
Posts: 1
Joined: Tue Aug 12, 2014 2:11 pm
Blog: View Blog (0)


Return to Crypto

Who is online

Users browsing this forum: No registered users and 0 guests