Posted: 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
Sponsor Sponsor
Delos
Posted: Mon Mar 27, 2006 8:40 am Post subject: (No 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!
Imm0rtal
Posted: Mon Mar 27, 2006 8:49 am Post subject: (No subject)
I am explaining an XoR encryption!
codemage
Posted: Mon Mar 27, 2006 10:06 am Post subject: (No subject)
I like how you've placed "compiled" in quotes.
md
Posted: Mon Mar 27, 2006 10:28 am Post subject: (No 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.
Delos
Posted: Mon Mar 27, 2006 10:53 am Post subject: (No subject)
Imm0rtal wrote:
I am explaining an XoR encryption!
Sure you are! Still not a Tut though. But there's time yet...
Imm0rtal
Posted: Mon Mar 27, 2006 10:55 am Post subject: (No subject)
codemage wrote:
I like how you've placed "compiled" in quotes.
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..
Cornflake can you explain in greater detail? Thanks
MysticVegeta
Posted: Mon Mar 27, 2006 11:24 am Post subject: (No 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.
Sponsor Sponsor
Imm0rtal
Posted: Mon Mar 27, 2006 12:35 pm Post subject: (No 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.
EDIT:
Delos wrote:
Imm0rtal wrote:
I am explaining an XoR encryption!
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.
Delos
Posted: Mon Mar 27, 2006 3:24 pm Post subject: (No subject)
Imm0rtal wrote:
I didn't realize all algorithems were the same. Please explain this theory in more depth.
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
md
Posted: Mon Mar 27, 2006 5:56 pm Post subject: (No 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.
Imm0rtal
Posted: Mon Mar 27, 2006 6:13 pm Post subject: (No subject)
Thank you sir.
Martin
Posted: Mon Mar 27, 2006 11:55 pm Post subject: (No subject)
Imm0rtal wrote:
codemage wrote:
I like how you've placed "compiled" in quotes.
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..
And C++ is just translated into assembly, which is just translated into machine code.
I couldn't resist. Sorry.
Imm0rtal
Posted: Tue Mar 28, 2006 1:37 am Post subject: (No subject)
Martin wrote:
Imm0rtal wrote:
codemage wrote:
I like how you've placed "compiled" in quotes.
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..
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.
jamonathin
Posted: Tue Mar 28, 2006 7:45 am Post subject: (No 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 .
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.