diff options
author | lloyd <[email protected]> | 2011-03-08 22:23:25 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-03-08 22:23:25 +0000 |
commit | 1a28f7ef6064041955e7a662c5e087bbea03b6ad (patch) | |
tree | 63046692850d3b2411001daf841a38c23016f123 /src/passhash | |
parent | e8ae96510f3d87e3b142df81b51c3b15e30e77f9 (diff) |
Use unique_ptr instead of auto_ptr
Use std::to_string in bcrypt
Diffstat (limited to 'src/passhash')
-rw-r--r-- | src/passhash/bcrypt/bcrypt.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/passhash/bcrypt/bcrypt.cpp b/src/passhash/bcrypt/bcrypt.cpp index e533c6081..3507db879 100644 --- a/src/passhash/bcrypt/bcrypt.cpp +++ b/src/passhash/bcrypt/bcrypt.cpp @@ -120,8 +120,13 @@ std::string make_bcrypt(const std::string& pass, std::string salt_b64 = bcrypt_base64_encode(&salt[0], salt.size()); - return "$2a$" + to_string(work_factor, 2) + "$" + salt_b64.substr(0, 22) + - bcrypt_base64_encode(&ctext[0], ctext.size() - 1); + std::string work_factor_str = std::to_string(work_factor); + if(work_factor_str.length() == 1) + work_factor_str = "0" + work_factor_str; + + return "$2a$" + work_factor_str + + "$" + salt_b64.substr(0, 22) + + bcrypt_base64_encode(&ctext[0], ctext.size() - 1); } } |