Guest User

Untitled

a guest
Aug 2nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Comparing Encrypted Passwords in Database and User Input With Encrypto
  2. var hasher = new Hasher();
  3.  
  4. hasher.SaltSize = 16;
  5.  
  6. //Encrypts The password
  7. var encryptedPassword = hasher.Encrypt(txtPass.Text);
  8.  
  9. Account newUser = new Account();
  10.  
  11. System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding();
  12.  
  13. newUser.accnt_User = txtUser.Text;
  14. newUser.accnt_Position = txtPosition.Text;
  15. newUser.accnt_Pass = new System.Data.Linq.Binary(encoding.GetBytes(encryptedPassword));
  16.  
  17. var hasher = new Hasher();
  18. hasher.SaltSize = 16;
  19. var hashedPasswordToStoreInDB = hasher.Encrypt(passwordToSet);
  20.  
  21. var hasher = new Hasher();
  22. hasher.SaltSize = 16;
  23. bool areEqual = hasher.CompareStringToHash(enteredPassword, hashFromDatabase);
Add Comment
Please, Sign In to add comment