asp.net-core – 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));
}

相关文章

ASP.NET与IIS是紧密联系的,由于IIS6.0与IIS7.0的工作方式的...
在之前的ASP.NET是如何在IIS下工作的这篇文章中介绍了ASP.NE...
这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...