Advertisement
bwall

Untitled

Jul 18th, 2012
1,338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. bool CheckPassword()
  2. {
  3. //Buffer used for the hash through the process
  4. unsigned char * output[32];
  5.  
  6. //Hash the password and the salt together
  7. SHA256 sha;
  8. sha.Update((unsigned char*)passkey, passlen);
  9. sha.Update((unsigned char*)salt, 32);
  10. sha.Finalize(output);
  11.  
  12. //Hash the hash N times(generally a large number of times)
  13. for (unsigned int i = 0; i < N; i++)
  14. {
  15. SHA256 sha2;
  16. sha2.Update(output, 32);
  17. sha2.Finalize(output);
  18. }
  19.  
  20. //The final hash to compare with the hash in the database
  21. SHA256 sha0;
  22. sha0.Update(output, 32);
  23. sha0.Finalize(output);
  24.  
  25. //Compare the hashes
  26. return (memcmp(temp, StoredKey, 32) == 0);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement