diff options
-rw-r--r-- | src/hashpwd.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/hashpwd.cpp b/src/hashpwd.cpp index 4931d93..414ffbd 100644 --- a/src/hashpwd.cpp +++ b/src/hashpwd.cpp @@ -1,11 +1,3 @@ -//============================================================================ -// Name : hashpwd.cpp -// Author : -// Version : -// Copyright : Your copyright notice -// Description : Hello World in C++, Ansi-style -//============================================================================ - #include <iostream> #include <sstream> #include <string> @@ -219,10 +211,7 @@ int main(int argc, char **argv) { SHA256_CTX sha256; unsigned char hash[SHA256_DIGEST_LENGTH]; - if (p) { - ((v == 1)) && cout << "Password: " << pwd << endl; - passwd_str = prefixStream.str() + pwd + salt; - } else { + if(!p) { passwd0 = did + "|" + mac; passwdnew = passwd0; @@ -239,9 +228,9 @@ int main(int argc, char **argv) { cout << endl; } pwd = ""; - binTo64(hash,SHA256_DIGEST_LENGTH,passwd_str,8); - (v == 1) && cout << "passwd_str: " << passwd_str << endl; - if(!badPassword(passwd_str)) + binTo64(hash,SHA256_DIGEST_LENGTH,pwd,8); + (v == 1) && cout << "passwd_str: " << pwd << endl; + if(!badPassword(pwd)) break; fudge++; memcpy(append,&fudge,sizeof fudge); @@ -262,16 +251,19 @@ int main(int argc, char **argv) { outencode << endl; #endif } - cout << "pass=" << passwd_str << endl; + + cout << "pass=" << pwd << endl; + + passwd_str = prefixStream.str() + pwd + salt; SHA256_Init(&sha256); SHA256_Update(&sha256,passwd_str.c_str(),passwd_str.length()); SHA256_Final(hash, &sha256); - cout << setw(2) << setfill('0') << hex; cout << "password_hash="; + cout << hex; for (int i=0; i < SHA256_DIGEST_LENGTH; i++) - cout << (int)hash[i]; + cout << setw(2) << setfill('0') << (int)hash[i]; cout << endl; cout << "salt=" << salt << endl; return 0; |