Tag: cryptographicexception

“解密表单cookie时,”在加密操作期间发生错误“

我已经将我的网站上传到网站主办,这个错误出现了; ‘ 在加密操作期间发生错误 。’。 我做了一些研究,似乎将经过forms化的cookie绑定到MachineKey(使用webhost时会有所不同)。 我找到了一个方法来解决这个问题,但错误仍然存​​在。 码: /// /// This method removes a cookie if the machine key is different than the one that saved the cookie; /// protected void Application_Error(object sender, EventArgs e) { var error = Server.GetLastError(); var cryptoEx = error as CryptographicException; if (cryptoEx != null) { FederatedAuthentication.WSFederationAuthenticationModule.SignOut(); Global.Cookies.FormAuthenticated Cookie = new […]

TripleDES:指定密钥是’TripleDES’的已知弱密钥,无法使用

我正在使用.NET 3.0类System.Security.Cryptography.MACTripleDES类来生成MAC值。 不幸的是,我正在使用一个使用“ 1111111111111111 ”(作为hex)作为单长DES密钥的硬件设备。 System.Security.Cryptography库对密钥进行一些健全性检查,如果您尝试使用加密弱密钥,则返回Exception。 例如: byte[] key = new byte[24]; for (int i = 0; i < key.Length; i++) key[i] = 0x11; byte[] data = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] computedMac = null; using (MACTripleDES mac = new MACTripleDES(key)) { computedMac = mac.ComputeHash(data); } 抛出一个例外 […]