How to Convert CAPICOM to .NET equivalent
This is the code from my VB6 app using CAPICOM
Set ed = New EncryptedData
ed.Algorithm =开发者_运维技巧 CAPICOM_ENCRYPTION_ALGORITHM_3DES
ed.SetSecret mySecret, CAPICOM_SECRET_PASSWORD
ed.Content = myText
myResult = ed.Encrypt(CAPICOM_ENCODE_BINARY)
but I need to convert the same functionality to VB.NET. Is there an equivalent to get the same values?
I went down this road, too. I made various attempts to decrypt data from VB6/CAPICOM using the crypto namespaces James mentioned above (without any luck).
According to the MS documentation, I am given the impression it is not possible to migrate your code to anything other than a P/Invoke call to the CAPI library. If you find yourself doing this, you might be better served creating a migration tool that decrypts using CAPI and then encrypts/exports the data using an open standard (sounds like CAPI is/will be deprecated).
As a start, look at the System.Security.Cryptography namespace. You'll find relevant classes there, include the TripleDES class.
精彩评论