CryptIt






4.11/5 (3投票s)
2000年5月8日

101069

1367
通过加密保护敏感数据
我看到一篇 Kurtz 的文章(1999年4月 - VCJ),并编写了一个简单的 ATL DLL,以便在 ASP 页面中使用它。我只是想展示几种(示例)实现它的方法。这篇文章包含 4 个项目:ATL(DLL)、VC++(使用 DLL)、VB(使用 DLL)和 ASP(使用 DLL)
所有这些都是他的代码 (ARACrypt.cpp/h),我只是用他的类来玩。
注意:我在 VB 示例中发现了一些有趣的事情。当我在 WinNT 上运行时,解密似乎无法正确工作(请参阅 VB 代码中的注释)。当我将返回的加密数据放入文本字段 (Text1.Text) 时,解密会出错(某些字符)。一旦我将返回的加密数据放入 String
变量中,一切都正常工作了(请参阅下面的 VB 代码)。在 Win2000 操作系统上,它以相反的方式正常工作……真奇怪?当然我修复了它,但如果你有两台操作系统(WinNT/Win2000),请检查一下。
Option Explicit ' MUST be registered Dim CryptTest As CRYPTITLib.Cryptor Private Sub Command1_Click() Set CryptTest = New CRYPTITLib.Cryptor CryptTest.PassPhrase = Text1.Text CryptTest.StringToCrypt = Text2.Text CryptTest.DoCrypting ' Normally I would not store to a string ' variable, update the text control, then ' use the variable to set the property (below) ' but WinNT 4.0 (SP3)/VB 6.0 (SP3) environment I get ' the wrong decryption...go figure? Try it: ' ' Text3.Text = CryptTest.ReturnCrypted ' ' CryptTest.StringToCrypt = Text3.Text ' ' The above does work on Win2000/VB 6.0 (SP3)!!! ' ' again, "go figure!" ' Dim strTest As String strTest = CryptTest.ReturnCrypted Text3.Text = strTest CryptTest.StringToCrypt = strTest CryptTest.DoCrypting Text4.Text = CryptTest.ReturnCrypted Set CryptTest = Nothing End Sub
我希望其他人觉得这有用。