寻找c#等效于php的password-verify() [英] looking for c# equivalent of php's password-verify()

查看:475
本文介绍了寻找c#等效于php的password-verify()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一堆用户帐户Moodle导入用c#编写的系统。



Moodle使用password_hash()函数创建密码的哈希值。我需要能够在c#中验证这些密码。



换句话说,我寻找ac#实现PHP的密码验证功能(
http://www.php.net/manual/en/function.password-verify.php ) 。



我已经google了一些,但是真的找不到任何关闭,所以我希望避免重复发明的方法: - )



谢谢!

解决方案

$ b

首先通过NuGet包安装CryptSharp。 (使用2.0官方包),顺便说一下,BCrypt.net不适合我。



然后:

 使用CryptSharp; 
bool matches = Crypter.CheckPassword(password goes here,hash here here);

请注意,哈希应以类似如下开头:
$ 2y $ ...



像一个魅力! : - )


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!

解决方案

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! :-)

这篇关于寻找c#等效于php的password-verify()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆