asp.net-core – CoreCLR中的哈希算法
发布时间:2020-12-15 23:27:57 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试在我的coreclr项目中使用这个 class,但是似乎找不到SHA256Managed的正确包.我已经尝试使用System.Security.Cryptography.Algorithms“:”4.0.0-beta-23409“,但它不包含SHA2565Managed的实现.还有其他替代方案来计算coreclr中的哈希值? 解决方法
我正在尝试在我的coreclr项目中使用这个
class,但是似乎找不到SHA256Managed的正确包.我已经尝试使用System.Security.Cryptography.Algorithms“:”4.0.0-beta-23409“,但它不包含SHA2565Managed的实现.还有其他替代方案来计算coreclr中的哈希值?
解决方法
您可以使用SHA256.Create()(从System.Security.Cryptography.Algorithms):
using (var algorithm = SHA256.Create()) { // Create the at_hash using the access token returned by CreateAccessTokenAsync. var hash = algorithm.ComputeHash(Encoding.ASCII.GetBytes(response.AccessToken)); // Note: only the left-most half of the hash of the octets is used. // See http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken identity.AddClaim(JwtRegisteredClaimNames.AtHash,Base64UrlEncoder.Encode(hash,hash.Length / 2)); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- ADO.NET实用经验 转载
- asp.net-mvc-3 – EF 4.1 Code First多个多对多关
- asp.net-mvc – ASP.NET MVC中的替代用户管理
- asp.net – 想要在ModalPopExtender之上显示Upda
- asp.net-mvc-3 – TextBoxFor vs EditorFor,和ht
- asp.net-mvc – 人们如何使用编辑器/显示模板与H
- asp.net-mvc – 创建一个值为0到10的asp.net mvc
- ASP.NET MVC – 使用ViewData将Json String传递给
- asp.net – 为什么有#!在我的角度应用程序的网址
- asp.net-core-mvc – 如何从任何ASP .Net Core类
热点阅读