Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

How To Use Bcrypt To Verify Password

$
0
0
// Below is my code
string mypas = "MyPass";
                         string mysalt = BCrypt.Net.BCrypt.GenerateSalt();
                         string myharsh = BCrypt.Net.BCrypt.HashPassword(mypas, mysalt);
// and i save to the database... then to verify the pass word 
my password = "MyPass";
//db.password is the harshed password stored on the database
bool validate = BCrypt.Net.BCrypt.Verify(mypas, db.Password);
            if(validate == true)
            {
                MyClass.MyAlert(this, "Correct Password Entered", "123");
                    return;
            }
            else
            {
                MyClass.MyAlert(this, "Incorrect password", "123");
                return;
            }
I have about 10 harshed password on my database... But when ever i verify all  the passwords, only one will work.. The first password i entered into the database.. the rest will not work.. Am i missing something?
Thanks, I really do appreciate your help..


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>