Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 17th, 2005, 10:56 PM   #1
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 646
Rep Power: 4 Jessehk is on a distinguished road
Any constructive criticism on a primitive text encryptor?

files can be found here:

http://hakuch.tripod.com/jesse/encrypt.cpp
http://hakuch.tripod.com/jesse/encryptM.cpp
http://hakuch.tripod.com/jesse/encrypt.h

I am in the process of making a text encryptor. Yes, I know my method of doing it it primitve, and probably useless, but I will buld from it.

Basically, user enters a word, for example, hello

for each letter of that word, a random number from 1 to 9 is generated.

That letter is incremented by that number, and the number is save to the key variable.

The user then gets the key, and the scrambled word.

I am working on a de-encryptor which will hopefully allow the user to read a key and scrambled message from a file, and also create the readable files.

Any suggestions or constructive criticism?
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote
Old Oct 17th, 2005, 11:51 PM   #2
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
There're only 9 possibilities for each letter of the word? I'm glad you're aware of its weakness :p
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Oct 18th, 2005, 7:36 AM   #3
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
maybe it's better to use xor
ivan is offline   Reply With Quote
Old Oct 18th, 2005, 8:50 AM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
You could add the ability for the user to specifiy the encryption offset via a config file. You can have more than 9 or 26... just loop through, when it its 9, start back at 0... or if you are doing alpha, when it hits 26 start back at 1.

You could also use character substitution, like a Ceasar Cipher to further "complicate" it. Maybe for the first letter of the word, count backwards to the offset and the next letter in the word, count forwards to the offset... etc.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Oct 18th, 2005, 9:17 AM   #5
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
Quote:
Originally Posted by ivan
maybe it's better to use xor
No. XOR is basically the same thing as long as there is a predetermined key like a number from 1-10 is used.
Quote:
Originally Posted by IR
You could add the ability for the user to specifiy the encryption offset via a config file. You can have more than 9 or 26... just loop through, when it its 9, start back at 0... or if you are doing alpha, when it hits 26 start back at 1.
That wouldn't complicate this much, as once you hit the sizeof the alphabet being used, it would be like starting from 0, but it would introduce the possibility of negative numbers for the key, which would be good.
Quote:
Originally Posted by IR
You could also use character substitution, like a Ceasar Cipher to further "complicate" it. Maybe for the first letter of the word, count backwards to the offset and the next letter in the word, count forwards to the offset... etc.
He is currently using a Caesar Cipher, as he is incrementing the letters of each word by the generated number. Do you mean count backwards by the offset, then forwards, like an alternating caesar shift?
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Oct 18th, 2005, 9:20 AM   #6
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
For better security you could also first reverse the file or something like that and then encrypth it.
ivan is offline   Reply With Quote
Old Oct 18th, 2005, 12:19 PM   #7
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Quote:
He is currently using a Caesar Cipher, as he is incrementing the letters of each word by the generated number. Do you mean count backwards by the offset, then forwards, like an alternating caesar shift?
Yes. I just realized he was using the CC... (too much code this morning).
What I was mentioning with the CC, is to alternate the direction of the offset. Say for instance:

phrase = "perl"
offset = 3

p + 3 = s
e - 3 = b
r + 3 = u
l - 3 = i

encrypted: sbui


But base it off ASCII, so you could use symbols and such as well. Plus a reversal pre or post encryption would be cool too, as ivan mentions.

I realize that this isn't 1028 bit or anything, probably 3 bit at best... But it gets the job done. If more security is needed look into TrippleDES or something similar... but I gather this is for learning purposes.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Oct 18th, 2005, 2:00 PM   #8
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
Quote:
I realize that this isn't 1028 bit or anything, probably 3 bit at best... But it gets the job done. If more security is needed look into TrippleDES or something similar... but I gather this is for learning purposes.
Well, the 1024 in 1024-bit encryption schemes refers to the maximum size of the key for ciphering, and as such, the original method would be only 8-bit. 1024/8 = 128 bytes, which is the maximum key-size for a scheme that is of that 'strength'. However, key-size is not the only, nor even primary contributing factor of strength in an encryption algorithm, else we'd all be using 32768-bit ciphers or the like :p

This is a good thread and project for learning the basics of encryption, though; yes.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Oct 18th, 2005, 2:52 PM   #9
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Oops. Fat fingered the 8... but see... at least you understood what I was trying to convey. Of course key size is not the only factor in the strength of an algorithm, but surely you agree that the longer the key, the better the encryption.

Thr ws a thrd sumwher abot typs. The thread was about reading sentences (like the previous one) full of typos straight through as if spelled correctly... realizing what words should be there or something... I think it was one of DaWei's creations. lol
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Oct 18th, 2005, 3:04 PM   #10
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
:p no worries, of course I got your intent.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC