.Net Core替代System.Web.Helpers.Crypto库

编程入门 行业动态 更新时间:2024-10-26 20:35:12
本文介绍了.Net Core替代System.Web.Helpers.Crypto库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们目前有一个现有项目,该项目使用Crypto库对密码进行哈希处理:

We currently have an existing project which uses to the Crypto library to hash passwords:

我们正在寻求转移到核心. 核心中是否有等效替代品,这样我们就不必重新哈希所有现有密码了?

We are looking to move over to core. Is there an equivalent replacement in core so that we do not have to re-hash all our existing passwords?

推荐答案

森林人,

>>我们正在寻求转移到核心. 核心中是否有等效的替代品,这样我们就不必重新哈希所有现有密码了?

根据您的描述,我创建了一个简单的asp核心应用程序,并尝试将块包添加到项目中.但该软件包与netcoreapp1.0和netcoreapp1.1不兼容,我建议您可以等待软件包升级 支持.Net Core.

According to your description, I create a simple asp core app and try to add the nugget package to project. but the package is not compatible with netcoreapp1.0 and netcoreapp1.1,I would suggest that you could wait for the package upgrade to support .Net Core.

您还可以编写自定义方法来哈希相关的密码.像这样:

You could also write custom method to hash related password. like this:

public static string HashPassword(string pass) { // generate a 128-bit salt using a secure PRNG byte[] salt = new byte[128 / 8]; using (var rng = RandomNumberGenerator.Create()) { rng.GetBytes(salt); } Console.WriteLine(

"盐:{Convert.ToBase64String(salt)})); //派生256位子项(使用HMACSHA1进行10,000次迭代) 散列的字符串= Convert.ToBase64String(KeyDerivation.Pbkdf2( 密码:密码, 盐:盐, prf:KeyDerivationPrf.HMACSHA1, 版本数:10000, numBytesRequested:256/8)); 返回散列; } "Salt: {Convert.ToBase64String(salt)}"); // derive a 256-bit subkey (use HMACSHA1 with 10,000 iterations) string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2( password: password, salt: salt, prf: KeyDerivationPrf.HMACSHA1, iterationCount: 10000, numBytesRequested: 256 / 8)); return hashed; }

docs.microsoft /en-us/aspnet/core/security/data-protection/consumer-apis/password-hashing

最诚挚的问候,

吴可乐

更多推荐

.Net Core替代System.Web.Helpers.Crypto库

本文发布于:2023-11-12 07:48:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580917.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:System   Core   Net   Crypto   Helpers

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!