Advertisement
asqapro

VectorSerialization

Jul 25th, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. struct bin{
  2.     void encrypt_vector(vector<string>& crypt){
  3.         modify_string.clear();
  4.         for(unsigned int i = 0; i < crypt.size(); ++i){
  5.             string word = crypt[i];
  6.             int mod_word[word.size()];
  7.             for(unsigned int x = 0; x < word.size(); ++x){
  8.                 stringstream ssl;
  9.                 stringstream ssn;
  10.                 string letter;
  11.                 char let = word[x];
  12.                 ssl << let;
  13.                 ssl >> letter;
  14.                 int num = encryption[letter];
  15.                 mod_word[x] = num;
  16.             }
  17.             modify_string.insert(modify_string.end(), mod_word, mod_word + word.size());
  18.             modify_string.push_back(.5);
  19.         }
  20.     }
  21.     void decrypt_vector(vector<int>& uncrypt){
  22.         string word;
  23.         for(unsigned int i = 0; i < uncrypt.size(); ++i){
  24.             int copy_iter = i;
  25.             int number = uncrypt[i];
  26.             for(it = encryption.begin(); it != encryption.end(); ++it){
  27.                 if(it->second == number){
  28.                     word.append(it->first);
  29.                     break;
  30.                 }
  31.             }
  32.             if(uncrypt[copy_iter++]==0){
  33.                 un_mod_vector.push_back(word);
  34.                 word.clear();
  35.                 continue;
  36.             }
  37.         }
  38.     }
  39. }binary;
  40.  
  41. binary.set_up_code();
  42. vector<string> thing;
  43. thing.push_back("apple");
  44. thing.push_back("pear");
  45. binary.encrypt_vector(thing);
  46. binary.decrypt_vector(binary.modify_string);
  47. for(vector<string>::iterator i = binary.un_mod_vector.begin();i!=binary.un_mod_vector.end();++i){
  48.     cout << *i << endl;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement