![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
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! |
|
|
|
|
|
#2 |
|
Professional Programmer
|
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;} |
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4
![]() |
maybe it's better to use xor
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#5 | |||
|
Professional Programmer
|
Quote:
Quote:
Quote:
__________________
% 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;} |
|||
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4
![]() |
For better security you could also first reverse the file or something like that and then encrypth it.
|
|
|
|
|
|
#7 | |
|
Programming Guru
![]() ![]() ![]() |
Quote:
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." |
|
|
|
|
|
|
#8 | |
|
Professional Programmer
|
Quote:
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;} |
|
|
|
|
|
|
#9 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#10 |
|
Professional Programmer
|
: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;} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|