Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- #include<vector>
- #include<sstream>
- #include<openssl/sha.h>
- #include<iomanip>
- int main() {
- //VERIABLES
- char chars[] = { '0', '1','2','3','4','5','6','7','8','9', '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', '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' };
- std::vector<int> password = { 0 };
- //
- SHA256_CTX sha256; //NEW
- std::stringstream hex_input; //NEW
- std::stringstream hex_output; //NEW
- unsigned char hash[SHA256_DIGEST_LENGTH]; //NEW
- //SIZES OF VERIABLES
- int chars_length = sizeof(chars) / sizeof(char);
- 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;
- }
- }
- //#####NEW#####
- //CLEAR hex_input and hex_output
- hex_input.str("");
- hex_output.str("");
- //CREATE THE COMBINATION
- for (int i2 = 0; i2 < password_length; i2++) {
- hex_input << chars[password[i2]];
- }
- //CREATE THE HASH
- SHA256_Init(&sha256);
- SHA256_Update(&sha256, hex_input.str().c_str(), hex_input.str().size());
- SHA256_Final(hash, &sha256);
- //CONVERT HASH TO PROPER HEX
- for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
- {
- hex_output << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
- }
- //PRINT OUT THE HASH
- std::cout << hex_input.str() << " = " << hex_output.str() << std::endl;
- //#############
- //std::cout << i << ": "; //DELETED
- //for (int i2 = 0; i2 < password_length; i2++) { //DELETED
- // std::cout << chars[password[i2]] << " "; //DELETED
- //} //DELETED
- //std::cout << "\n"; //DELETED
- //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