Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. char normalize(int badChar){
  2.     string static alphabet = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890$";
  3.     return alphabet[badChar % alphabet.length()];
  4. }
  5. string normalizeHash(string hash){
  6.     for(char& c: hash)
  7.         c = normalize(c);
  8.    
  9.     return hash;
  10. }
  11. string getHash(string key){
  12.     string hash64;
  13.     const int hashLength = 64;
  14.    
  15.     for(int stage = 0; stage < 2; ++stage) {
  16.         for (int i = 0; i < hashLength; ++i) {
  17.             char c = key[i % key.length()];
  18.             if(stage == 0)
  19.                 hash64 += c; // Добавим букву.
  20.        
  21.             // Изменим весь хеш по такому алгоритму:
  22.             for (char& hashChar: hash64)
  23.                 hashChar +=
  24.                         (
  25.                                 ((c * 37) | (i % c)) &
  26.                                 ( ((c / 3) << 5) / (c >> c % 3) )
  27.                         ) + (hashChar / c);
  28.        
  29.         }
  30.        
  31.         hash64.reserve();
  32.     }
  33.    
  34.     return normalizeHash(hash64);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement