Computer Science Canada

Not Another Encryption!!

Author:  Imm0rtal [ Mon Mar 27, 2006 1:38 am ]
Post subject:  Not Another Encryption!!

I have released brutal/LONG yet effective code that allows you to use the most simple yet most popular commercial encryption. Exclusive OR!!

I have no idea if this was done before but how XOR works is as such:

This algorithm takes a secret key (as most alogrithems do) and converts each byte to a decimal then converts your entire phrase to Decimals. Then it proceeds to XOR each byte or DEC with your key.

EXAMPLE:
Key: 12
Message: aaaaaaaa

So..

Xor Each Byte (Key is Repeated)
12121212
aaaaaaaa

After Encryption:
PSPSPSPS

So how do you decrypt it? This is why XOR is such a favorite among programmers trying to protect files. The encryption method is the same as the decryption method.

Xor Each Byte (Key is Repeated)
12121212
PSPSPSPS

After Encryption:
aaaaaaaa


So it looks simple.. But like every encryption.. its only as powerful as its weakest part. The key you make has NO limitations in this program except that it must be smaller then the information you wish to encrypt (or the same size)

Also note: Turing cannot display bytes with the decimal value of "00"(Null) or "128" (Ç). If anyone knows a way to fix this.. I would love to hear it.. As of now I have a if statement that just changes them to the Decimal (255). This will mess with your encryptions but the idea was to send your encryption to a text file which should be fairly easy.

I make no apologies for how exagerated this code may be.. I am not a turing expert in any sense of the word..

NOW THE CODE!

code:


%"Compiled" with Version: 4.0.5 of Turing.

%Your passkey (Must be shorter or equal the same amount of characters as your message)
var key : string := "12"
var information : string := "aaaaaaaa" %You Protected Info!
var output : string := "" %The Output Text (Decrypted or Encrypted)
var xor2string : int := 0

var keyletter : array 1 .. length(key) of string
var keybytes : array 1 .. length(key) of int
var keymax : int

var infoletter : array 1 .. length(information) of string
var infobytes : array 1 .. length(information) of int
var infomax : int
 %Start of Encryption



% Convert Key To Decimals
for x : 1 .. length (key)
keyletter(x) := key (x)
keybytes(x) := ord(keyletter(x))

if x = length (key) then %Find Length of key
keymax := x
end if
end for

% Convert information to Decimals
for y : 1 .. length (information)
infoletter(y) := information (y)
infobytes(y) := ord (infoletter(y))

if y = length (information) then %Find Length of information
infomax := y
end if
end for

 %End of Encryption
var x : int := 0 % Key Array
var y : int := 0  % Info Array

loop
y := y + 1
x := x + 1


xor2string := (keybytes(x) xor infobytes(y))

if xor2string = 0 or xor2string = 128 then
xor2string := 255  %Protection against unsupported Bytes (0) (128)
end if
output := output + chr(xor2string)

if x = keymax then
x := 0
end if

exit when y = infomax

end loop
put ""
put "Your Key Was: ", key
put "Your Original Message Was: ", information
put "Encrypted Your Message Was: ", output

Author:  Delos [ Mon Mar 27, 2006 8:40 am ]
Post subject: 

Please indent your code. This technically is not a Tutorial, so unless you prove otherwise, I'll move it to [Source].
You have 24 hours, go!

Author:  Imm0rtal [ Mon Mar 27, 2006 8:49 am ]
Post subject: 

I am explaining an XoR encryption! Razz

Author:  codemage [ Mon Mar 27, 2006 10:06 am ]
Post subject: 

I like how you've placed "compiled" in quotes. Laughing

Author:  md [ Mon Mar 27, 2006 10:28 am ]
Post subject: 

if you turn your encrypted byte into two 4bit chunks and add those to a base byte you can encode the message using only 16 characters (base to base+15). That prevents problems with using characters that would otherwise have meaning, like the end of file character.

Author:  Delos [ Mon Mar 27, 2006 10:53 am ]
Post subject: 

Imm0rtal wrote:
I am explaining an XoR encryption! Razz


Sure you are! Still not a Tut though. But there's time yet...

Author:  Imm0rtal [ Mon Mar 27, 2006 10:55 am ]
Post subject: 

codemage wrote:
I like how you've placed "compiled" in quotes. Laughing


Despite what most people on this forum say.. its still just a translation to C++ as far as I am concerned.. but lets not start this arguement again.. Laughing

Cornflake can you explain in greater detail? Thanks

Author:  MysticVegeta [ Mon Mar 27, 2006 11:24 am ]
Post subject: 

Well I would agree with Delos, its more of a source code than its a tutorial but I would like to point one thing out, shoudnt this be an extention to my tut on encryption? I mean Why not move his post in the end of that thread and delete this thread? Cause its really the same topic, and it isnt that big to have th eneed to be covered in 2 topics.

Author:  Imm0rtal [ Mon Mar 27, 2006 12:35 pm ]
Post subject: 

MysticVegeta wrote:
Well I would agree with Delos, its more of a source code than its a tutorial but I would like to point one thing out, shoudnt this be an extention to my tut on encryption? I mean Why not move his post in the end of that thread and delete this thread? Cause its really the same topic, and it isnt that big to have th eneed to be covered in 2 topics.


I didn't realize all algorithems were the same. Please explain this theory in more depth. Smile


EDIT:

Delos wrote:
Imm0rtal wrote:
I am explaining an XoR encryption! Razz


Sure you are! Still not a Tut though. But there's time yet...


www.dictionary.com wrote:

tu·to·ri·al Audio pronunciation of "Tutorial" ( P ) Pronunciation Key (t-tôr-l, -tr-, ty-)
n.
Something that provides special, often individual instruction, especially:


www.dictionary.com wrote:

ex·plain Audio pronunciation of "explain" ( P ) Pronunciation Key (k-spln)
v. ex·plained, ex·plain·ing, ex·plains
v. tr.

1. To make plain or comprehensible.


Since we can both agree I was explaining an XoR encryption and according to the english dictionary it means the same thing to explain something or tutor someone about something... You really should have came to this answer yourself.. But I am a kind man.

Author:  Delos [ Mon Mar 27, 2006 3:24 pm ]
Post subject: 

Imm0rtal wrote:

I didn't realize all algorithems were the same. Please explain this theory in more depth. Smile


Same topic not algorithms. What Mystic said was actually true. Seeing as these are tutorials *cough* it makes more sense for them to be centralized than to have a thousand different ones covering the same ideas and sets of algorithms. More on this later.


Imm0rtal wrote:

Since we can both agree I was explaining an XoR encryption and according to the english dictionary it means the same thing to explain something or tutor someone about something... You really should have came to this answer yourself.. But I am a kind man.


I'll answer your slew of quotations, with some of my own.

Cervantes wrote:

Tutorials will have certain requirements placed on them. They must:

  • have good, well-commented example(s). The more the merrier.
  • pose questions for readers to solve on their own.
  • supply answers to these questions at the end of the tutorial.
  • be formatted well. Introduction, body, conclusion. The body should be split up into sub-topics.
  • use headers.
  • bold key terms.

A good looking tutorial is always nice. Your tutorial will double as eye-candy if you add some colour.


So, while this may explain a topic, it still does not qualify as a Tutorial on said topic. And yes, there are many other similar poser-tuts out there. All I have to say is that the world will be a better, cleaner place in V3.

Now, back to the Mystic point. If you're amenable to the idea, we could have this, uh, "tut" of yours amended then appended to Mystic's - and of course credit would be given. This would effectively put all info into one place - seeing as he did start explaining XOR in his but didn't get too far.
However, this would require you reading this and bringing your info up to the level that Cornflake alluded to.

tick tock

Author:  md [ Mon Mar 27, 2006 5:56 pm ]
Post subject: 

Ok, simple example of what I mean. First you encrypt your string using method X. For the sake of simplicity lets assume that this method gives you a string of characters after encryption, and that each character will have a value between 0-255. Since many of those characters have meanings that prevent you from using them we need a way to re-encode characters so that only a limited set of characters that don't interfere with other things are used.

To that end, say out encrypted string ends up being the byte pattern 0x00 0xFF 0x3C 0x56. Notice that 0x00 is a reserved character (when it comes to text mode files). To keep things running fine we need to re-encode teh characters so that 0x00 does not appear, and since out string can contain all the rest of 0x00-0xFF we can't just replace it with something else without breaking the encryption.

So, the simplest solution is to take each character and split it up into 4bit numbers. Our new string would then be 0x0 0x0 0xF 0xF 0x3 0xC 0x5 0x6.

Just storing these numbers as characters still leaves us with problems, but at least we've shrunk the range of possible values from 256 to 16. There are more hten 16 letters, so why not bump the numbers up so that they start at 'A'.

then we get the nice final encrypted string of (assuming 0x50 is 'a') 0x50 0x50 0x5F 0x5F 0x53 0x5C 0x55 0x56. A nice string that looks like gibberish, contains no reserved characters and by going backwards is easy decryptable.

This might not be the best description... but if you really want me to try and explain better see the IRC channel.

Author:  Imm0rtal [ Mon Mar 27, 2006 6:13 pm ]
Post subject: 

Thank you sir. Smile

Author:  Martin [ Mon Mar 27, 2006 11:55 pm ]
Post subject: 

Imm0rtal wrote:
codemage wrote:
I like how you've placed "compiled" in quotes. Laughing


Despite what most people on this forum say.. its still just a translation to C++ as far as I am concerned.. but lets not start this arguement again.. Laughing


And C++ is just translated into assembly, which is just translated into machine code.

I couldn't resist. Sorry.

Author:  Imm0rtal [ Tue Mar 28, 2006 1:37 am ]
Post subject: 

Martin wrote:
Imm0rtal wrote:
codemage wrote:
I like how you've placed "compiled" in quotes. Laughing


Despite what most people on this forum say.. its still just a translation to C++ as far as I am concerned.. but lets not start this arguement again.. Laughing


And C++ is just translated into assembly, which is just translated into machine code.

I couldn't resist. Sorry.


How mature.. are you gonna make a post like this in evey thread that discusses Turing as a language? Is it really THAT important to you that everyone believes what you do? Interesting...

Note to Mod: If it makes you happy then delete this thread.. I was only trying to help.. in truth this XOR encryption was just for personnal use. You can post dictionary definations until your fingers go numb.. Tutor and Explain mean the same thing. NOT everyone in the world knows what an Xor encrpytion is.. same as NOT everyone in the world knows what a Array is. Thats why we have tutorials. Theres no other explanation of XOR anywhere on the turing related forums that I could find.

End Of Arguement. Delete the thread if your not convinced.

Author:  jamonathin [ Tue Mar 28, 2006 7:45 am ]
Post subject: 

I've juss been kinda watchin this thread to see if you would convince Delos in time, and it's become a bit interesting, but your last post seems a little . . incorrect Imm0rtal.
Imm0rtal wrote:

How mature.. are you gonna make a post like this in evey thread that discusses Turing as a language? Is it really THAT important to you that everyone believes what you do? Interesting...

He was just quoting from what you said - so was this really necessary?

Imm0rtal wrote:

Note to Mod: If it makes you happy then delete this thread..

In this entire thread there is no talk of deleting the thread, rather than moving it to Source code - since that's what it mainly is. Never said getting rid of it, I'm shure your efforts are aprreciated.

Imm0rtal wrote:

You can post dictionary definations until your fingers go numb..

Maybe it's just me, but I *believe* you are the only one to post a dictionary definition Laughing.

But like I said earlier, no one is talking about getting rid of this topic, jus moving it to where the Mods believe it should be, and since they kinda run this boat, it should probabily go to Source.

Author:  Delos [ Tue Mar 28, 2006 10:54 am ]
Post subject: 

Hey, you even got a couple extra hours! Anyhow, the offer/suggestion to have your XOR encryption included into Mystic's tut (which would then become your's and Mystic's tut) still stands - since he did make the point of asking for more advanced encryption methods to be included.

I'm also a little confused at that little tirade of yours - exploding at both Martin and I...Very Happy. Ah well. If it made you feel better.

Anyhow, this thread has gotten *way* off topic anyhow, and shall be moved to [Source]. I expect that we'll be seeing an update to Mystic's tut sooner rather than later.
When you've drafted your final tut (working w/ Mystic of course), PM either myself or Cervantes and we'll proof it and send you the BBCode to keep it in line with the other upscale tuts.

As a side note: if this was intended to 'explain' or 'tutor' as you said, then chances are it'll get more game time in [Source] than in [Tutorials], simply because people come here less frequently. So while we can have dozens of posts in [Source] detailing the same topics, we can just have one comprehensive on in [Tutorials].

Author:  upthescale [ Tue Mar 28, 2006 10:19 pm ]
Post subject: 

wtf all u had to do is

put"your key was 12"
put"your original message was aaaaa"
put"Encrpyt....."
u get hte point? u put sooo muh coding when all u ahd to add was 3 lines

Author:  Delos [ Tue Mar 28, 2006 11:13 pm ]
Post subject: 

Sorry, what?

upthescale, before you make an utter idiot out of yourself, again, please try and come to grips with this little piece of advice: read the whole topic, understand the whole topic, and try to make sense when you post...[sigh].

The only mention of lacking code in here was cleared up completely by Cornflake. This, of course, involved some rather advanced topics based upon base manipulation. And no, I'm not talking about pH and buffers either.
Now, if you have nothing better to do than attempt to impose your apparently meaningless and ill-thought out ideas upon the rest of us, please move on. This is your second warning in the space of three days. Those are not good numbers.

I suggest you either apologise to Imm0rtal for wrongfully critisizing his work, or if you really do have a construtive comment to make, then by all means please do so in a comprehendable manner.
Whipping up a quick comment and not even bothering to use [code] tags or for that matter, some semblence of grammar is simply a testament to your inability to formulate coherent thoughts. Of course no one is going to "get the point" in such a case. Rolling Eyes

Author:  Martin [ Tue Mar 28, 2006 11:24 pm ]
Post subject: 

Imm0rtal wrote:
Martin wrote:
Imm0rtal wrote:
codemage wrote:
I like how you've placed "compiled" in quotes. Laughing


Despite what most people on this forum say.. its still just a translation to C++ as far as I am concerned.. but lets not start this arguement again.. Laughing


And C++ is just translated into assembly, which is just translated into machine code.

I couldn't resist. Sorry.


How mature.. are you gonna make a post like this in evey thread that discusses Turing as a language? Is it really THAT important to you that everyone believes what you do? Interesting...

Note to Mod: If it makes you happy then delete this thread.. I was only trying to help.. in truth this XOR encryption was just for personnal use. You can post dictionary definations until your fingers go numb.. Tutor and Explain mean the same thing. NOT everyone in the world knows what an Xor encrpytion is.. same as NOT everyone in the world knows what a Array is. Thats why we have tutorials. Theres no other explanation of XOR anywhere on the turing related forums that I could find.

End Of Arguement. Delete the thread if your not convinced.


It was moved to Turing source just because it was more of a learn by example thing than a tutorial. Don't take it as an insult, it has nothing to do with the quality of the content, only the style.

As for the Turing thing, it's not a point of view. Turing is a programming language, in the exact same way that Perl and Ruby and Java are programming languages. As one of this site's humble moderators, it's my duty to keep everyone informed.
Wikipedia wrote:
A compiler is a computer program (or set of programs) that translates text written in a computer language (the source language) into another computer language (the target language).
http://en.wikipedia.org/wiki/Compiler

Author:  codemage [ Wed Mar 29, 2006 11:09 am ]
Post subject: 

I think it's neat how, the next time someone looks up encryption or XOR, they'll be happy to see that there's a post that meets their search criteria, and then be even more happy to find two whole pages of flame. Embarassed

Author:  Delos [ Wed Mar 29, 2006 2:01 pm ]
Post subject: 

codemage wrote:
I think it's neat how, the next time someone looks up encryption or XOR, they'll be happy to see that there's a post that meets their search criteria, and then be even more happy to find two whole pages of flame. Embarassed


That happens frequently Shocked!


: