# Encryption suggestions?

• 12-03-2002
joshdick
Encryption suggestions?
I need to design a final project to complete before Christmas vacation for my programming class. My teacher suggested I write a program that encrypts and decrypts messages.
Now, don't get me wrong, I'm not a helpless student programmer, and I'm not asking anyone to write any code for me. I'd just like some suggestions as to what encryption method to use. A comprehensive description of an algorithm or some pseudocode or a link to a good website would be greatly appreciated.

A few considerations:
This course is a first semester course in C++. Although I know how to use arrays and other things we haven't been taught in class, my teacher doesn't appreciate it when I use those concepts in my programs in his class. :mad:
When I did a search of this forum and Google for encryption methods, I kept seeing ciphers using the XOR(^) operator. Although I would like to learn about it, my teacher wouldn't appreciate it if I used something like that that he didn't teach. :(
My project needs to keep my interest untill Christmas break, so I need something more complicated than just a Caesar cipher.

Sorry for the long post. I will be grateful for any help I get. Thank you.
• 12-03-2002
MrWizard
Look up polygraphic system and Hill ciphers. The basic idea is that you divide the plaintext message into groups of letters and encipher the plaintext group by group. You can use matrix transformations in your encryption also. I don't really have time to explain it all though. You can find lots of good articles on it though. I don't know if this is the scope you're looking for or not. Good luck.
• 12-03-2002
joshdick
Mr. Wizard, thanks for the suggestion, but I'd like to stay away from matrix operations if at all possible. Somehow, none of my math teachers taught me anything about matrices all through high school. I'm not sure how that happened: I've always been in the highest level math classes and I'm a senior now.

Anyway, I would be open to more suggestion, hopefully sans matrices.
• 12-04-2002
devour89
the encryption i use for my save games in my game is

encryption:
Code:

```#include <iostream.h> #include <windows.h> #include <fstream.h> void EncryptString(char* String) {   int Length = strlen(String);   for(int i=0; i<Length; i++)   {       String[i]++;   } } int main() {    ofstream outfile;  char encr[256];  cout<<"Type a string to encrypt(type * and then enter to encrypt): ";  cin.getline(encr, 256, '*');  EncryptString(encr);  outfile.open("encr.txt", ios::binary|ios::trunc);  outfile<<encr;  outfile.close();  Sleep(3000);    return 0;   }```
decryption:
Code:

```#include <iostream.h> #include <windows.h> #include <fstream.h> #include <conio.h> #include <conio.c> #include <string.h> #define PASSWORD "password" void DecryptString(char* String) {   int Length = strlen(String);   for(int i=0; i<Length; i++)   {       String[i]--;   } } int main() { ifstream infile; char encr[250]; char pass[50]; int fail;  cout<<"A small hint...";  cout<<"\n\nThe password is: "<<strlen(PASSWORD)<<" characters long";  Sleep(2000);  clrscr();  cout<<"Password: ";  cin>>pass;  if(strcmpi(PASSWORD, pass) == 0)  {   cout<<"\n\nCorrect...";   Sleep(2500);   clrscr();   cout<<"Encrypted Data: \n\n\n";   infile.open("encr.txt", ios::binary);   infile >> encr;   infile.close();   DecryptString(encr);   cout<<encr;   getchar();   return 0;  }  else  {   while(strcmpi(PASSWORD, pass) != 0)   {   if(fail == 5)   {   clrscr();   cout<<"\nSorry...";   getchar();   exit(1);   }   fail++;   cout<<"\n\nIncorrect...";   Sleep(2500);   clrscr();   cout<<"Password: ";   cin>>pass;   }   cout<<"Correct...";   Sleep(2500);   clrscr();   cout<<"Encrypted Data: \n\n\n";   infile.open("encr.txt", ios::binary);   infile >> encr;   infile.close();   DecryptString(encr);   cout<<encr;   getchar();   return 0; } }```

for me that is unreadable enough...it becomes even worse when you save it as binary as well
• 12-04-2002
Magos
Quote:

Originally posted by devour89
for me that is unreadable enough...it becomes even worse when you save it as binary as well [/B]
For minor things (like game saves) that encryption will probably be a good choice, but if you want a higher level encryption, look up RSA encryption.
• 12-04-2002
GuestTrauts
If you want something extremely wimpy, try taking the input

(say it is 0123456789 as a string)

and rearrange it to

0246813579

Then do this:

for (x=0; char[x] != '\0'; x++)
char[x]=char(int(char[x])+1);

that should add one to the ASCII value, making a very very simple encryption.

Maybe then convert to binary and rearrange the characters again? Not very strong, but that should be material covered in the class
• 12-04-2002
Davros
If you want to create a grown-up encryption program, see the following RC4 algorithm.

http://www.columbia.edu/~ariel/ssleay/rrc4.html
• 12-04-2002
joshdick
Quote:

Originally posted by Davros
If you want to create a grown-up encryption program, see the following RC4 algorithm.
Although that seems to be a good idea, my class, unfortunately, hasn't covered structs, static, or pointers :mad:

Quote:

If you want something extremely wimpy. . .
I don't want something extremely whimpy. I need something that will keep me busy untill Christmas break.

Right now it looks like my top candidates are the Vigenere Cipher and RSA. If anybody can provide any more suggestions, I'm still open. Thanks to everyone for your help :)
• 12-04-2002
Davros
>Although that seems to be a good idea, my class, unfortunately, hasn't covered structs, static, or pointers

>Right now it looks like my top candidates are the Vigenere Cipher and RSA

RSA? You mean public/private key? LOL. Implementing this will be a challenge, especially if you're not using pointers.

Your best bet is a Vigenere Cipher.