Computer Science Canada encryption program |
Author: | zylum [ Mon Mar 08, 2004 6:32 pm ] | ||
Post subject: | encryption program | ||
here is a simple encryption program i made... what can i do to improve it?
-zylum |
Author: | Mazer [ Mon Mar 08, 2004 6:58 pm ] |
Post subject: | |
I don't know a whole lot about encryption techniques but I do no that the exit statement should be inside the case construct if you don't want it to crash. (ie, "label 4: exit" and take out the exit when line, or add "label :" and leave the rest) It looks pretty good, by the way. |
Author: | Delta [ Wed Apr 21, 2004 10:05 am ] | ||
Post subject: | |||
ok first of all....
this is not good.... when creating your new key... this randomizes all the characters in the key...meaning some can be the same...meaning your ecryption does not work properly... at least theres a chance that it won't |
Author: | Andy [ Fri Apr 23, 2004 10:29 am ] |
Post subject: | |
i made an simple encryption program in c++ too lazy to convert it to turing, so here's my encrypt and decrpt functions btw it only works for 10 letters max or something like that... //encryption program string encrypt(char word[]) { //used for holding data char tempword[15],final[15]; int val[15],j,tempval; string encrypted; //encrypt the data for (int i=0;i<strlen(word);i++) val[i]=i; for (i=0;i<strlen(word);i++) { j=rand()%strlen(word); tempval=val[i]; val[i]=val[j]; val[j]=tempval; } for (i=0;i<strlen(word);i++) { tempword[i]=word[val[i]]; final[i]=val[i]+48; } tempword[strlen(word)]='\0'; final[strlen(word)]='\0'; strcat(final,tempword); for (i=0;i<strlen(final);i++) final[i]+=((i%3)-1)*i; encrypted=final; return encrypted; } //decryption program string decrypt(string word) { //used for holding data char tempword[15],final[15]; int val[15]; string decrypted; for (int i=0;i<word.length();i++) final[i]=word[i]; final[word.length()]='\0'; for (i=0;i<strlen(final);i++) final[i]-=((i%3)-1)*i; for (i=0;i<strlen(final)/2;i++) { val[i]=final[i]-48; tempword[i]=final[i+(strlen(final)/2)]; } tempword[strlen(final)/2]='\0'; for (i=0;i<strlen(tempword);i++) final[val[i]]=tempword[i]; final[strlen(tempword)]='\0'; decrypted=final; return decrypted; } its simple but its pretty good |
Author: | white_dragon [ Fri Apr 23, 2004 5:34 pm ] |
Post subject: | |
WOW!!!! out of all da possibilities i got da same character! anywho. yeah just like Delta said, use someting else rather than tat. good job |
Author: | WhatAmIDoing [ Fri Apr 23, 2004 8:43 pm ] |
Post subject: | |
it's a good idea but it won't work. you can't change the encrypyion back if u want. a code is a set thing not random. but good try |
Author: | Catalyst [ Fri Apr 23, 2004 10:17 pm ] |
Post subject: | |
hes right u need way of saving or sending the key along (too many non-alpha numeric chars for the person to write down, the chr codes would be better) and inputting the key into the prog other wise u can only decrypt the message from the instance of the program that created it which makes it useless |
Author: | jdworrow [ Sun Apr 25, 2004 9:00 am ] |
Post subject: | |
Well, I'm still a little rough around the edges with things in Turing. But I liked the basics of the encryption program. Very good idea to move forward on. [/img] |
Author: | Delta [ Tue Apr 27, 2004 12:29 pm ] | ||
Post subject: | |||
Here is my encryption program... its got a set key that allows proper encryption and decryption.(proper meaning it works correctly) give it a try.
|
Author: | WhatAmIDoing [ Wed Apr 28, 2004 11:24 am ] |
Post subject: | |
here is my encryption program var sentence : string var number : int loop put "" put "Please enter your message:('exit' to quit) " .. get sentence : * exit when sentence = "exit" for i : 1 .. length (sentence) number := ord (sentence (i)) if number = 90 then number := 64 elsif number = 122 then number := 96 elsif number = 32 then number := 31 end if put chr ((number) + 1) .. end for end loop if u want to decrypt just keep typing in the letters and eventualyy yuo'll get back to original message |