Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char normalize(int badChar){
- string static alphabet = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890$";
- return alphabet[badChar % alphabet.length()];
- }
- string normalizeHash(string hash){
- for(char& c: hash)
- c = normalize(c);
- return hash;
- }
- string getHash(string key){
- string hash64;
- const int hashLength = 64;
- for(int stage = 0; stage < 2; ++stage) {
- for (int i = 0; i < hashLength; ++i) {
- char c = key[i % key.length()];
- if(stage == 0)
- hash64 += c; // Добавим букву.
- // Изменим весь хеш по такому алгоритму:
- for (char& hashChar: hash64)
- hashChar +=
- (
- ((c * 37) | (i % c)) &
- ( ((c / 3) << 5) / (c >> c % 3) )
- ) + (hashChar / c);
- }
- hash64.reserve();
- }
- return normalizeHash(hash64);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement