c# - 寻找 c# 相当于 php 的 password-verify()

标签 c# php passwords cryptography

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

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

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

我用谷歌搜索了一下,但真的找不到任何接近的东西,所以我问是希望避免重新发明轮子:-)

谢谢!

最佳答案

知道了!

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

然后:

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

请注意,散列应以类似以下内容开头: “$2y$...”

工作起来很有魅力! :-)

关于c# - 寻找 c# 相当于 php 的 password-verify(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22615648/

相关文章:

c# - 在 Linux 上从命令行启动 C# 程序

c# - 如何从 Kinect 深度数组中获取位置 (x,y)?

php - 如何从android发送长数组到php服务器

php - Web 服务(学期)类(class)中的基本主题是什么?

git - github 或 bitbucket 上的私有(private)存储库是否可以安全地存储密码?

c# - 使用 sp_help_job 在 C# 中检查 SQL 作业状态

c# - 设置处理器关联性和 TPL

PHP 银条 ORM : Duplicate key value violates unique constraint for DataObject write

python - 我可以采取哪些安全措施来保护无法在数据库中进行哈希处理的密码?

C# 通过 Process 的 StandardInput 传递密码