Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Encryption Logic

Author
Message
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 9th Jun 2007 18:25
I have been trying to figure out how to make an encryption program, and I am successful with the exception that the encryption is not very strong.

By not very strong I mean, the encrypted string has the same number of characters as the decrypted string, and same letters have the same encrypted character.

What advise do you guys have about making an encryption algorithm that has a different number of characters than the start and no double characters to represent a double character in the decrypted version.

When describing the logic to me try to be as pseudobasic as possible. Language is not important to me. Only the logic.

Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 9th Jun 2007 18:56 Edited at: 9th Jun 2007 19:01
Here is one way, but it doesn't change the file size:

Create a string to hold the password.
Read in the file to be encrypted one byte at a time.
For each byte, take the next letter in the string.
When you reach the end of the string go back to the start.
For each letter, find its ascii equivelant, and do a bitwise XOR of the two byte values.
Write the new byte value to the new file.

To decrypt, just run the encrypt function on it again with the same password.

edit:
Here is some example code:


Killswitch
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 9th Jun 2007 19:14
You could always introduce some characters in random places after or even before encryption, so long as you know where they are. It's not a particularly neat method, but since I'm pretty sure you're not coding up an algorithim for the government I'm sure it'll be alright.



~Heed my word hobags: Jism~
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 9th Jun 2007 19:25
Diggsey
I like your idea, but I am a bit confused. You say to decrypt I would just run the encrypt function on the file again? Well wouldn't that just encrypt it a second time? Wouldn't I have to run the encrypt function on it backwards to decrypt it? As for a bitwise XOR I am unsure what that is. I will probably have to google it.

Killswitch
Your idea is clever as well. Although it is not too professional it does the trick.


I forgot to mention that I was basing it off a password. Wasn't doing it the same way as Diggsey, but I like his idea.

If Diggsey could go a little more in depth or if someone else could post with their thoughts, please do.

Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Jun 2007 21:48
Basically, the password you use for the xor operation acts as a key. When you encrypt the data, its like locking a door with the key. Using the same key you unlock the door when you decrypt.


Let's encrypt the letter 'A', ascii value of 65.
Our password(key) is 'K', ascii value of 75.
The encrypted letter will be ascii value 10. (E=encrypted)

A: 01000001
K: 01001011
E: 00001010


When xoring 2 bits, 1 is returned when either bit is 1 but not both. So 0 is returned when both bits are either 1's or 0's. Basically, if the bits don't match, the result is 1.

So now lets decrypt 'E' using our key 'K'.
('D' = decrypted)

E: 00001010
K: 01001011
D: 01000001

Notice how our decrypted value once again equals 'A'?


Login to post a reply

Server time is: 2024-11-18 17:51:24
Your offset time is: 2024-11-18 17:51:24