Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool CheckPassword()
- {
- //Buffer used for the hash through the process
- unsigned char * output[32];
- //Hash the password and the salt together
- SHA256 sha;
- sha.Update((unsigned char*)passkey, passlen);
- sha.Update((unsigned char*)salt, 32);
- sha.Finalize(output);
- //Hash the hash N times(generally a large number of times)
- for (unsigned int i = 0; i < N; i++)
- {
- SHA256 sha2;
- sha2.Update(output, 32);
- sha2.Finalize(output);
- }
- //The final hash to compare with the hash in the database
- SHA256 sha0;
- sha0.Update(output, 32);
- sha0.Finalize(output);
- //Compare the hashes
- return (memcmp(temp, StoredKey, 32) == 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement