首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HashAlgorithms in CoreCLR

HashAlgorithms in CoreCLR
EN

Stack Overflow用户
提问于 2015-10-20 19:28:28
回答 1查看 9K关注 0票数 20

我正在我的coreclr项目中尝试使用这个class,但是我似乎找不到正确的SHA256Managed包。我试过使用System.Security.Cryptography.Algorithms":"4.0.0-beta-23409“,但它不包含SHA2565Managed的实现。在coreclr中还有其他计算哈希值的方法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-20 20:02:43

您可以从命名空间SHA256.Create()使用System.Security.Cryptography

(汇编:System.Security.Cryptography.Algorithms__)

代码语言:javascript
复制
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, 0, hash.Length / 2));
}
票数 39
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33245247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档