Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

looking for c# equivalent of php's password-verify()

I need to import a bunch of user accounts Moodle into a system written in c#.

Moodle uses password_hash() function to create hashes of passwords. I need to be able to verify these passwords in c#.

In other words I looking for a c# implementation of PHP's password verify function ( http://www.php.net/manual/en/function.password-verify.php ).

I've googled a bit but couldn't really find anything close, so I am asking in hopes of avoiding reinventing the wheel :-)

Thanks!

like image 763
Filip Avatar asked Mar 24 '14 16:03

Filip


1 Answers

Got it!

First install CryptSharp via NuGet Package. (Use the 2.0 "official" package), and by the way, BCrypt.net didn't work for me.

Then:

using CryptSharp;
bool matches = Crypter.CheckPassword("password goes here", "hash goes here");

Note that hash should start with something like: "$2y$..."

Works like a charm! :-)

like image 167
Filip Avatar answered Nov 08 '22 23:11

Filip