字符串加密/解密 [英] string encryption/decryption

查看:121
本文介绍了字符串加密/解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很感兴趣是否可以使用Excel Visual Basic和某些加密服务提供程序进行字符串加密/解密.

I am interested if it's possible to do string encryption/decryption using Excel Visual Basic and some cryptographic service provider.

我发现了一个演练在Visual Basic中加密和解密字符串,但似乎仅对独立的Visual Basic有效.

I have found a walk-through Encrypting and Decrypting Strings in Visual Basic, but it seems it's valid for standalone Visual Basic only.

那么您会建议我使用另一种加密方法还是演示如何对Excel Visual Basic采用演练?

So would you suggest me another encryption method or show how the walk-through could be adopted for Excel Visual Basic?

推荐答案

您提供的链接显示了如何使用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.

这篇关于字符串加密/解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆