-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow_api_hahsing.cpp
More file actions
52 lines (39 loc) · 1.24 KB
/
Copy pathwindow_api_hahsing.cpp
File metadata and controls
52 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
int main() {
//Declaring variables
int numWinApi;
std::cout << "Enter the Windows Api you wish to hash";
std::cin >> numWinApi;
std::vector<std::string> winApiList;
std::string tempWinApi;
std::cin.ignore();
std::cout << "Please enter the " << numWinApi << " windows API you wish to hash: " << std::endl;
//gets users input
for (int i = 0; i < numWinApi; ++i) {
std::cout << "Windows API " << i + 1 << ": ";
std::getline(std::cin, tempWinApi);
winApiList.push_back(tempWinApi);
}
for (const auto& wins : winApiList) {
int iteration = 0;
unsigned int hash = 0x35;
for (char eachChar : wins) {
//converts to ascii
iteration++;
int asciiValue = static_cast<int>(eachChar);
//hashing algorithm
hash += (hash * 0xab10f29f + asciiValue) & 0xffffff;
std::cout << "Iteration " << iteration << " : " << eachChar
<< " :0x" << std::hex << asciiValue << " :0x" << hash << std::dec
<< std::endl;
}
//displays result
std::cout << "Final Hash for " << wins << ": 0x" << std::setfill('0')
<< std::setw(8) << std::hex << hash << std::dec << std::endl;
}
return 0;
}