【问题标题】:Padding is invalid and cannot be removed填充无效且无法移除
【发布时间】:2012-02-06 15:31:48
【问题描述】:

例外: 来源:mscorlib 信息: 内边距无效,无法移除。

堆栈跟踪:

at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) 
at System.Security.Cryptography.CryptoStream.FlushFinalBlock() 
at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) 
at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) 
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context) 
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

我们的机器键也没有设置为自动。所以有人可以帮忙。谢谢

【问题讨论】:

标签: asp.net cryptography rijndaelmanaged


【解决方案1】:

加密消息的来源是什么?如果您确定密钥和 IV 匹配,那么您必须查看分组密码模式(例如 CBC、CTR、ECB)和填充模式是否在过程的两端也匹配。如果所有这些加起来,那么很可能你在加密和解密之间截断了字节数组,可能是由于一个错误的原因。

发布您的一些代码可能有助于我们诊断。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-26
    • 1970-01-01
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    • 2010-10-10
    • 1970-01-01
    • 2016-07-18
    相关资源
    最近更新 更多