Click here to Skip to main content
15,894,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day all, I downloaded Bcrypt for password encryption, but i am having little with issues with saving it on my database and verifying the password..

C#
//Code below
string mysalt = BCrypt.GenerateSalt(12);
           string myharsh = BCrypt.HashPassword(txtpassword.Text, mysalt);
//Now i want to confirm if the record exist on my database
var check = (from c in k.passwordtable select c).FirstOrDefault();
string password = check.passoword;
 if (BCrypt.CheckPassword(txtpassword.Text, check) == true)
{
lblconfirm = "Password Exist";
}
else
{
check.password = myharsh;
k.savechanges();
lblconfirm = "added";
}

//from the code above i have tried using similar password just to confirm, but its not working, 
//but if i try it without checking the database it works
like this
 if (BCrypt.CheckPassword(txtpassword.Text, myharsh) == true)
{
lblconfirm = "Password Exist";
}
else
{
lblconfirm = "Password does not Exist";
}
// how do i retrieve record from the databse and confirm it before saving it to the database to avoid duplicate.
//Thanks, I do appreciate your time and effort
Posted
Comments
[no name] 21-Jul-14 7:45am    
You do some research on how to connect to whatever database you are using and how to query data out of it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900