Having some problems creating an encoder for class. I have the decoder, but I can't seem to make my encoder work properly.
I have attached the decoder to the post as a file.
Encryption example: "Hello" would be "xxxxx!H#xxxxxxx#e¤xxx¤l&xxxxxxxxx&l$xxxxxxxxxxx$o", where x is randomly generated letters, and ! is the first key. After the first key comes the first character in the message, and then the next key.
What I am having problems with is simply what to use... I tried using only char[] and loops, but was unable to separate the independent characters in the message when introducing them to the encoded string. I got H, He, Hel, Hell, Hello in the encoded string instead of the single characters. Perhaps I have to use arrays?
For creating new keys, I used
#include <iostream>
#include <ctime>
using namespace std;
int main() {
srand((unsigned) time(NULL));
char c = (char) (rand() % 26 + 'a');
cout << char(c) << endl;
cout << int(c) << endl;
}
However, I was unable to integrate them into the encryption due to type differance. I managed to go from char to char[], but I got the ASCII number instead of the letter.
Meh. Any suggestions?