Something along the lines of:
original text: My cats stinks
key: Im very hungry
it takes M and the ASCII # and adds it to the ASCII value of I and then encrypts that into 14+9 =25( if those are the ASCII #, cant remember) so that should be Y. That way there is structure to the code and it can be cracked. A friend of mine ( a girl) is currently in a c++ course at my university. And I kind of want to send her this code with of course a different message and tell her how to crack it. Im not going to send her the entire code below so that she does not get the original text ( as that is the point). But I think she would find this somewhat cute and fun so why not
I have this code below which the 26 is because there is that many letters in the alphabet. I know this code is very easy to crack, but that is fine it is supposed to be
offset = (KeyLetter - 'A') + 1
encryptedLetter = 'A' + (original distance from 'A' + offset) % 26
encryptedLetter = 'A' + (originalletter - 'A' + offset) % 26
Using this template:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string original = "My cats stinks";
cout << "Original data = " << original;
string encrypted = "";
string unencrypt = "";
char key = 'x';
for (int temp = 0; temp < original.size(); temp++){
encrypted += original[temp] ^ (int(key) + temp) % 255;
}
cout << "nEncrypted data = " << encrypted;
for (int temp = 0; temp < original.size(); temp++){
unencrypted += encrypted[temp] ^ (int(key) + temp) % 255;
}
cout << "nUnencrypted data = " << unencrypt;
}
This post has been edited by ishkabible: 05 April 2012 - 04:45 PM
Reason for edit:: fixed code tags

New Topic/Question
Reply



MultiQuote




|