且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

字符串加密/解密

更新时间:2022-03-18 05:02:42

您提供的链接显示了如何使用VB.NET并因此使用.NET Framework进行字符串加密和解密.

The link you provide shows how to perform string encryption and decryption using VB.NET, and thus, using the .NET Framework.

当前,Microsoft Office产品尚不能使用用于应用程序的Visual Studio工具组件使Office产品可以访问.NET框架的BCL(基类库),而BCL又可以访问基础Windows CSP(密码服务器提供程序),并为这些加密/解密功能提供一个很好的包装器.

Currently, Microsoft Office products cannot yet use the Visual Studio Tools for Applications component which will enable Office products to access the .NET framework's BCL (base class libraries) which, in turn, access the underlying Windows CSP (cryptographic server provider) and provide a nice wrapper around those encryption/decryption functions.

暂时,Office产品仍旧使用旧的VBA( Visual Basic for Applications ),它基于Visual Basic的旧VB6(或更早版本)版本,而该版本基于COM,而不是.NET Framework.

For the time being, Office products are stuck with the old VBA (Visual Basic for Applications) which is based on the old VB6 (and earlier) versions of visual Basic which are based upon COM, rather than the .NET Framework.

由于所有这些,您要么需要调出Win32 API来访问CSP函数,要么必须使用纯VB6/VBA代码自行拥有"加密方法,尽管这是可能不太安全.这完全取决于您希望加密的安全性".

Because of all of this, you will either need to call out to the Win32 API to access the CSP functions, or you will have to "roll-your-own" encryption method in pure VB6/VBA code, although this is likely to be less secure. It all depends upon how "secure" you'd like your encryption to be.

如果您想自己动手"基本的字符串加密/解密例程,请查看以下链接以开始使用:

If you want to "roll-your-own" basic string encryption/decryption routine, take a look at these link to get you started:

轻松加密字符串
使用可读字符串更好地进行XOR加密

Encrypt a String Easily
Better XOR Encryption with a readable string

vb6-加密功能
Visual Basic 6/VBA字符串加密/解密功能

vb6 - encryption function
Visual Basic 6 / VBA String Encryption/Decryption Function

如果要访问Win32 API并使用基础的Windows CSP(安全得多的选项),请参阅以下链接,以获取有关如何实现此目的的详细信息:

If you want to access the Win32 API and use the underlying Windows CSP (a much more secure option), see these links for detailed information on how to achieve this:

如何在Visual Basic 6.0中加密字符串

How to encrypt a string in Visual Basic 6.0

访问CryptEncrypt VBA中的(CryptoAPI/WinAPI)功能

最后一个链接可能是您想要的链接,其中包括一个完整的VBA类模块,用于包装" Windows CSP功能.

That last link is likely the one you'll want and includes a complete VBA Class module to "wrap" the Windows CSP functions.