Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct bin{
- vector<int> modify_string;
- map<string, int> encryption;
- void set_up_code(){
- string alphabet[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
- int letter_num=1;
- for(int i = 0; i < 27; ++i){
- string letter = alphabet[i];
- encryption.insert(pair<string,int>(letter,letter_num));
- letter_num++;
- }
- }
- void encrypt(string& crypt){
- for(unsigned int i = 0; i < crypt.size(); ++i){
- stringstream ssl;
- string letter;
- char let = crypt[i];
- ssl << let;
- ssl >> letter;
- int num = encryption[letter];
- modify_string.push_back(num);
- }
- }
- void decrypt(vector<int>& uncrypt){
- map<string, int>::iterator it;
- for(unsigned int i = 0; i < uncrypt.size(); ++i){
- int number = uncrypt[i];
- for(it = encryption.begin(); it != encryption.end(); ++it){
- if(it->second == number){
- cout << it->first;
- break;
- }
- }
- }
- }
- }binary;
- binary.set_up_code();
- character.race_class = "human_orc";
- binary.encrypt(character.race_class);
- binary.decrypt(binary.modify_string);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement