寻找C#相当于PHP的的密码验证() [英] looking for c# equivalent of php's password-verify()

查看:161
本文介绍了寻找C#相当于PHP的的密码验证()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要进口一堆用户帐户进入的Moodle用C#编写的系统。

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

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

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

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

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 ).

我GOOGLE了一下,但不能真正找到任何接近,所以我在避免重复发明轮子的希望问:-)

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

谢谢!

推荐答案

明白了!

首先通过的NuGet包安装CryptSharp。 (使用2.0官方包),并顺便,BCrypt.net没有为我工作。

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

然后:

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



需要注意的是哈希应该是这样开始:
$ 2Y $ ...

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

工程就像一个魅力! : - )

Works like a charm! :-)

这篇关于寻找C#相当于PHP的的密码验证()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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