c# – JWT Web令牌加密 – SecurityAlgoritms.HmacSha256 vs Sec
发布时间:2020-12-15 22:41:24 所属栏目:百科 来源:网络整理
导读:对于基于令牌的身份验证,Microsoft.IdentityModel.Tokens提供了可用于创建SigningCredentials的安全算法列表: string secretKey = "MySuperSecretKey"; byte[] keybytes = Encoding.ASCII.GetBytes(secretKey); SecurityKey securityKey = new SymmetricSec
对于基于令牌的身份验证,Microsoft.IdentityModel.Tokens提供了可用于创建SigningCredentials的安全算法列表:
string secretKey = "MySuperSecretKey"; byte[] keybytes = Encoding.ASCII.GetBytes(secretKey); SecurityKey securityKey = new SymmetricSecurityKey(keybytes); SigningCredentials signingCredentials = new SigningCredentials(securityKey,SecurityAlgorithms.HmacSha256); SigningCredentials signingCredentials = new SigningCredentials(securityKey,SecurityAlgorithms.HmacSha256Signature); HmacSha256和HmacSha256Signature有什么区别?你什么时候使用签名而不是非签名?** 还有其他算法“非签名”和“签名”算法 – RsaSha256和RsaSha256 解决方法
HmacSha256是一个字符串常量,评估为“HS256”. HmacSha256Signature也是一个字符串常量,但计算结果为“
http://www.w3.org/2001/04/xmldsig-more#hmac-sha256”
System.IdentityModel.Tokens.SecurityAlgorithms的最新定义不包括HmacSha256,而是允许您为SigningCredentials分离签名和摘要算法. 您应该使用HmacSha256Signature来保护您的应用程序,因为HmacSha256看起来已被弃用. 来自Microsoft文档……
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 派生类中的Marshal XMLAttribute
- ruby-on-rails – configuration.rb:140:在`co
- 插件开发技术说明(4)---xml编程
- [2015-01-27]XML笔记_XML、DTD、Schema
- cocos2dx: win32工程Release 和 Debug版本使用的
- 细致入微:Oracle中执行计划在Shared Pool中的存
- c# – Microsoft XNA可以在Windows 10上运行吗?
- ios – 在Xcode中调试时,我可以在应用程序中看到
- 如何压缩JSONObject在Android中通过Http发送它?
- SQLite操作指南(SQLite version 3.6.21)
热点阅读