在Excel中加密和解密字符串 [英] Encrypting and decrypting strings in Excel

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

问题描述

我有兴趣,如果可以使用Excel Visual Basic和一些加密服务提供商进行字符串加密/解密。



我发现了一个演练在Visual Basic中加密和解密字符串,但它似乎仅适用于独立的Visual Basic。 / p>

那么你会建议我另一种加密方法,还是演示Excel Visual Basic可以采用的演练方式?

解决方案

您提供的链接显示如何使用VB.NET执行字符串加密和解密,从而使用.NET Framework。



目前,Microsoft Office产品尚未使用 Visual Studio工具应用程序组件,这将使Office产品访问.NET框架的BCL(基类库) ries),这反过来访问底层的Windows CSP(加密服务器提供程序),并提供围绕这些加密/解密功能的好包装。



目前,Office产品被老版本VBA( Visual Basic for Applications )所困扰,它基于旧的VB6(和更早版本的基于COM的visual Basic版本,而不是.NET Framework。



由于所有这些,您将需要调用Win32 API访问CSP功能,或者您将必须在纯VB6 / VBA代码中滚动自己的加密方法,尽管这可能不太安全。这一切都取决于你想要加密的安全。



如果要滚动自己的基本字符串加密/解密例程,看看这些链接让你开始:



轻松加密字符串

使用可读字符串更好的XOR加密

vb6 - 加密功能

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



如果要访问Win32 API并使用底层的Windows CSP(更安全的选项),请参阅这些链接以获取有关如何实现的详细信息:



如何加密Visual Basic 6中的字符串.0

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



最后一个链接可能是您想要的,并包含一个完整的VBA Class模块来包装Windows CSP功能。


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

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

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

解决方案

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

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.

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.

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:

Encrypt a String Easily
Better XOR Encryption with a readable string
vb6 - encryption function
Visual Basic 6 / VBA String Encryption/Decryption Function

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:

How to encrypt a string in Visual Basic 6.0
Access to CryptEncrypt (CryptoAPI/WinAPI) functions in VBA

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

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

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