diff options
author | John Klug <john.klug@multitech.com> | 2017-03-21 14:25:05 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2017-03-21 14:25:05 -0500 |
commit | 272561073825a1152c5e349a8c1c540abb9c38c1 (patch) | |
tree | 1a6052ed114f726a2491726a2eafe67e1b4eb1bb | |
parent | 6179a6109cc0f523fefa15112714ebb54be49eec (diff) | |
download | mts-id-eeprom-272561073825a1152c5e349a8c1c540abb9c38c1.tar.gz mts-id-eeprom-272561073825a1152c5e349a8c1c540abb9c38c1.tar.bz2 mts-id-eeprom-272561073825a1152c5e349a8c1c540abb9c38c1.zip |
every output must reset the width of the field in C++
-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; |