From 272561073825a1152c5e349a8c1c540abb9c38c1 Mon Sep 17 00:00:00 2001 From: John Klug Date: Tue, 21 Mar 2017 14:25:05 -0500 Subject: every output must reset the width of the field in C++ --- src/hashpwd.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/hashpwd.cpp') 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 #include #include @@ -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; -- cgit v1.2.3