Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MY CRAPPY YOUTUBE https://www.youtube.com/channel/UC9kD0oE90HfCZvMAPzRLf3w
- #include<iostream>
- #include<math.h>
- #include<vector>
- #include<sstream>
- #include<openssl/sha.h>
- #include<iomanip>
- int main() {
- //VERIABLES
- char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- std::vector<int> password = { 0 };
- SHA256_CTX sha256;
- std::stringstream hash_input;
- std::stringstream hash_output;
- unsigned char hash[SHA256_DIGEST_LENGTH];
- //SIZES OF VERIABLES
- int chars_length = (sizeof(chars) / sizeof(char))-1;
- int password_length = password.size();
- //ADD AN ADDITIONAL CHARACTER TO PASSWORD VECTOR FOREVER IN A LOOP
- while (true) {
- //CYCKLE TROUGH ALL OF THE COMBINATIONS
- for (int i = 0; i < pow(chars_length, password_length); i++) {
- //CYCKLE TROUGH ALL OF THE VERIABLES IN ARRAY
- for (int i2 = 0; i2 < password_length; i2++) {
- //IF VERIABLE IN "PASSWORD" ARRAY IS THE LAST VERIABLE IN CHAR "CHARS" ARRRAY
- if (password[i2] == chars_length) {
- //THEN INCREMENT THE NEXT VERIABLE IN "PASSWORD" ARRAY
- password[i2 + 1]++;
- //AND RESET THE VERIABLE BACK TO ZERO
- password[i2] = 0;
- }
- }
- //CLEAR hash_input and hash_output
- hash_input.str("");
- hash_output.str("");
- //CREATE THE COMBINATION
- for (int i2 = 0; i2 < password_length; i2++) {
- hash_input << chars[password[i2]];
- }
- //CREATE THE HASH
- SHA256_Init(&sha256);
- SHA256_Update(&sha256, hash_input.str().c_str(), hash_input.str().size());
- SHA256_Final(hash, &sha256);
- //CONVERT HASH TO PROPER HEX
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
- {
- hash_output << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
- }
- //PRINT OUT THE HASH
- std::cout << hash_input.str() << " = " << hash_output.str() << std::endl;
- //INCREMENT THE FIRST VERIABLE IN ARRAY
- password[0]++;
- }
- //ADDS ANOTHER CHARACTER TO THE PASSWORD VECTOR
- password.push_back(0);
- //UPDATE THE SIZE OF THE PASSWORD VECTOR
- password_length = password.size();
- //RESET PASSWORD VECTOR ELEMENTS BACK TO ZEROES
- std::fill(password.begin(), password.end(), 0);
- }
- }
Add Comment
Please, Sign In to add comment