通过我们的遗留VB6应用程序,我使用CAPICOM库加密了大量数据。
我需要从.Net 3.5应用程序访问这些数据,但是当我调用Decrypt方法时收到错误:"ASN1 bad tag value met“。谷歌在寻找像样的代码样本或解释这个错误的含义方面帮助不大。
下面的代码几乎完全复制了VB6代码中发生的事情:
static string DecryptEncryptedText(string encryptedText, string secretKey)
{
var encryptedDataObj = new CAPICOM.EncryptedData();
encryptedDataObj.SetSecret(secretKey, CAPICOM_SECRET_TYPE.CAPICOM_SECRET_PASSWORD);
encryptedDataObj.Decrypt(encryptedText);
return encryptedDataObj.Content;
}发布于 2010-02-16 11:59:03
当我收到这个错误时,是因为我使用了错误的密钥进行解密。你检查过你的secretKey的编码吗?我怀疑数据是用VB6中的ANSI字符串加密的,而您在新代码中使用的是Unicode字符串。
https://stackoverflow.com/questions/2255474
复制相似问题