Advertisement
asqapro

SaveToFile

Jul 23rd, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. struct bin{
  2.     map<string, int> encryption;
  3.     void set_up_code(){
  4.         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"};
  5.         int letter_num=1;
  6.         for(int i = 0; i < 26; ++i){
  7.             string letter = alphabet[i];
  8.             encryption.insert(pair<string,int>(letter,letter_num));
  9.             letter_num++;
  10.         }
  11.     }
  12.     void encrypt(string& modify){
  13.         int mod_array[modify.size()];
  14.         for(unsigned int i = 0; i < modify.size(); ++i){
  15.             stringstream ss;
  16.             string letter;
  17.             char c = modify[i];
  18.             ss << c;
  19.             ss >> letter;
  20.             mod_array[i] = encryption[letter];
  21.         }
  22.         for(int x = 0;x < modify.size(); ++x){
  23.             cout << mod_array[x];
  24.         }
  25.     }
  26.     void decrypt(){
  27.         //
  28.     }
  29. }binary;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement