System.Security.Cryptography.CryptographicException
来源:互联网 发布:hadoop yarn 源码下载 编辑:程序博客网 时间:2024/05/19 16:50
项目背景: asp.net mvc升级到5.2.0.0,web.config的System.Web設置了machineKey
错误:在cshtml的@Html.AntiForgeryToken()抛出System.Security.Cryptography.CryptographicException异常
解决:重置web.config的静态机器码
参考:http://msdn.microsoft.com/en-us/library/ms998288.aspx
1:使用 RNGCryptoServiceProvider 类创建一个随机秘钥
2:选择一个适当的秘钥大小,如下:
1) SHA1, set the validationKey to 64 bytes (128 hexadecimal characters).
2)AES, set the decryptionKey to 32 bytes (64 hexadecimal characters).
3)3DES, set the decryptionKey to 24 bytes (48 hexadecimal characters).
3:创建一个console application生成key,如下代码:
using System;using System.Text;using System.Security;using System.Security.Cryptography;class App { static void Main(string[] argv) { int len = 128; if (argv.Length > 0) len = int.Parse(argv[0]); byte[] buff = new byte[len/2]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); rng.GetBytes(buff); StringBuilder sb = new StringBuilder(len); for (int i=0; i<buff.Length; i++) sb.Append(string.Format("{0:X2}", buff[i])); Console.WriteLine(sb); }}
0 0
- System.Security.Cryptography.CryptographicException
- DotNetNuke: System.Security.Cryptography.CryptographicException: Bad Data
- .NET:System.Security.Cryptography.CryptographicException 的解决办法
- System.Security.Cryptography.CryptographicException: 密钥集不存在。
- System.Security.Cryptography.CryptographicException: 系统找不到指定的文件。
- System.Security.Cryptography.CryptographicException: 系统找不到指定的文件
- 部署时System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
- C# System.Security.Cryptography.CryptographicException: 系统找不到指定的路径。
- 获取证书私钥 报“System.Security.Cryptography.CryptographicException”类型的异常
- System.Security.Cryptography实战
- System.Security.Cryptography加密。
- System.Security.Cryptography
- 开发微信发红包时,本地测试没有问题发布IIS上提示 System.Security.Cryptography.CryptographicException: 系统找不到指定的文件。
- System.Security.Cryptography实战(图)
- System.Security.Cryptography C# 加密和解密的学习
- Computer Security and Cryptography
- .NET Security and Cryptography
- Computer Security and Cryptography
- 门户型网站和业务型平台的菜单有什么不同?
- 九度OJ 1549 货币问题 (模拟)
- 第17周 项目4 - 日期结构体<2>
- git与svn的部分区别以及《pro git》部分章节读书笔记
- java基础-HashMap动态扩容数据转移源码阅读
- System.Security.Cryptography.CryptographicException
- 第十七周项目2---引用作形参
- Format是CString类的一个成员函数
- iOS - ShareSDK 短信验证码开发记录
- apache+mysql+php之集成环境wampserver安装篇
- Android strings.xml 的特殊字符_安卓strings.xml 添加空格或字符的方法
- 第17周项目4-日期结构体(生日差)
- IOS8界面调整自适应属性后无效的解决方法
- AMT的bug