从 VBA (MS Access) 解密 PGP 加密文件的最简单方法
我需要编写代码从 FTP 位置获取 PGP 加密的文件并处理它们。 这些文件将使用我的公钥进行加密(我还没有公钥)。 显然,我需要一个可以在 Microsoft Access 中使用的 PGP 库。 您能推荐一款易于使用的吗?
我正在寻找不需要大量 PKI 知识的东西。 理想情况下,能够轻松生成一次性私钥/公钥对,然后有一个简单的解密例程的东西。
I need to write code that picks up PGP-encrypted files from an FTP location and processes them. The files will be encrypted with my public key (not that I have one yet). Obviously, I need a PGP library that I can use from within Microsoft Access. Can you recommend one that is easy to use?
I'm looking for something that doesn't require a huge amount of PKI knowledge. Ideally, something that will easily generate the one-off private/public key pair, and then have a simple routine for decryption.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
命令行解决方案很好。 如果您的数据库是内部应用程序,而不是重新分发,我可以推荐 Gnu Privacy Guard。 这个基于命令行的工具将允许您执行与 OpenPGP 标准相关的任何操作。
在 Access 中,您可以在宏中使用 Shell() 命令,如下所示:
这将运行命令行工具来解密文件。 此语法使用您的秘密密码的纯文本版本。 这不是最安全的解决方案,但如果您的数据库是内部的并且仅由受信任的人员使用,则可以接受。 GnuPG 支持其他技术来保护密码。
A command line solution is good. If your database is an internal application, not to be redistributed, I can recommend Gnu Privacy Guard. This command-line based tool will allow you to do anything that you need to with regard to the OpenPGP standard.
Within Access, you can use the Shell() command in a Macro like this:
This will run the command-line tool to decrypt the file. This syntax uses a plaintext version of your secret passphrase. This is not the most secure solution, but is acceptable if your database is internal and only used by trusted personnel. GnuPG supports other techniques to secure the passphrase.
PGP 有一个用于解密文件的命令行选项。
我们有一个执行解密的批处理文件,传入要解密的文件名:
批处理文件:
我们从 VBS 中调用它:
希望这能为您指明一个有用的方向。
PGP has a commandline option for decrypting files.
We have a batchfile that does the decryption, passing in the filename to be decrypted:
Batch file:
We than call that from a VBS:
Hope that points you in a useful direction.
您可以使用 OpenPGPBlackbox(ActiveX 版本) 来实现此目的
You can use OpenPGPBlackbox (ActiveX edition) for this
Stu...我曾经不得不用 Java 编写一个“安全 SMTP”服务器...最简单、最快的方法是下载和/或购买 PGP。 他们有一个 SDK,您可以使用它来访问任何您想要的内容。
我必须回去看看是否需要编写一个 COM 包装器,或者他们是否已经有了一个。 (我大约 10 年前编写了这个 SMTP 服务器)。 无论如何,不要灰心。 大约 5 年前,我用 C++ 编写了一个完整的基于 PGP 的应用程序(基于 openPGP RFC),但问题是,我不允许使用任何现有的库。 所以我必须自己写所有这些东西。 而且,我使用 GPG、OpenPGP 和 PGP 进行测试等...
所以,我什至可以为您提供有关如何在 VBA 中解码这些内容的帮助。 这并非不可能(它可能会很慢,但并非不可能),而且我不是一个“掏出并运行命令行东西来为你做这样的工作的人,因为它会让你面临一些严重的安全风险” ,因为 hurcane 的建议(例如)将导致您的密码短语显示给 ProcExp 等工具。第一步是学习 PKE 的工作原理等。然后,您需要执行的步骤就是我想要的
。我有兴趣提供帮助,因为我总是会编写每个人都说无法完成的代码:) 另外,由于合并、关闭等原因,我拥有我编写的应用程序的源代码。它
最初是为石油和天然气行业编写的,所以我知道它是安全的,这并不是说我的代码没有任何安全缺陷,但我认为它是稳定的。我的中文余数理论代码有问题。由于某种原因,当我使用该快捷方式时,我无法正确解码数据,但如果我使用 RSA“长路”,它就可以工作...
现在,这个应用程序从未完全完成,所以我不支持 DSA 密钥对之类的东西,但我确实支持 RSA 密钥对、SHA1、MD5、使用 IDEA、AES(我认为我的 3DES 代码确实支持无法正常工作,但我可能已经解决了这个问题)。 我还没有实现压缩等等...但是,我很想有一个理由再次回去处理这段代码。
我/可以/为您创建一个 COM 对象,您可以从 VBA 调用该对象,传递原始 Base64 数据以及 Base64 密钥数据(或指向磁盘上密钥文件的指针),以及用于解码文件的 passpsshrase... 多年来
想想看...让我知道..
,我收集了用于执行 MD5、SHA1、IDEA 和其他加密例程等操作的 vbScript 代码,但我没有编写它们。 天哪,您可能只需与 Microsoft 的 CryptoAPI 进行交互,并将每个操作分解为其核心部分,并且仍然可以正常工作。 (你不会找到像“DecryptPGP()”这样的 Micosoft CryptoAPI 调用......这一切都必须分块完成)。
让我知道我是否可以帮忙。
Stu... I once had to write a "Secure SMTP" server in Java... The easiest, and quickest way to do this is to download and/or purchase PGP. They have an SDK that you can use to access in anything you want.
I'd have to go back and see if I had to write a COM wrapper, or if they already had one. (I wrote this SMTP server about 10 years ago). Anyways, don't get discouraged. About 5 years ago, I wrote an entire PGP based application (based on the openPGP RFC) in C++, but the catch was, I was NOT allowed to use any existing libraries. So I had to write all that stuff myself. And, I used GPG, OpenPGP, and PGP for testing, etc....
So, I could even provide help for you on how to decode this stuff in VBA. It's not impossible, (it may be slow as hell, but not impossible), and I'm NOT one to "shell out and run cmdline stuff to do work like this for you, as it will open you up to some SERIOUS security risks, as hurcane's suggestion (for example) will cause your passphrase to be displayed to tools like ProcExp). The first step is learning how PKE works, etc. Then, the steps you need to do to get what you want.
This is something I'd be interested in helping with since I'm always one to write code that everyone says can't be done. :) Plus, I own the source code of the app I wrote, because of of mergers, closures, etc...
It was originally written for the Oil and Gas industry, so I know it's secure. That's not to say I don't have ANY security flaws in the code, but I think it's stable. I know I have an issue with my Chinese Remainder Threory code.. For some reason when I use that short-cut, I can't decode the data correctly, but if I use the RSA "long way" it works...
Now, this application was never fully finished, so I don't support things like DSA Key-pairs, but I do support RSA key pairs, with SHA1, MD5, using IDEA, AES, (I THINK my 3DES code does not work correctly, but I may have fixed that since). I didn't implement compression yet, etc... But, I'd love a reason to go back and work on this code again.
I /COULD/ make you a COM object that you could call from VBA passing the original Base64 data in, along with the Base64 key data, (or a pointer to a key file on disk), and a passpsshrase to decode files....
Think about it... Let me know..
Over the years, I have collected vbScript code for doing things like MD5, SHA1, IDEA, and other crypto routines, but I didn't write them. Hell, you could probably just interface with Microsoft's CryptoAPI, and break each action down to it's core parts and still get it to work. (You will not find a Micosoft CryptoAPI call like "DecryptPGP()"... It'd all have to be done in chunks).
Lemme know if I can help.
我会寻找一个命令行加密器/解密器,然后使用正确的参数从 Access 应用程序中调用 exe。
据我所知,VBA 中没有 PGP 加密器/解密器。
I would look for a command line encrypter / decrypter and just call the exe from within your Access application, with the right parameters.
There is no PGP encrypter / decrypter in VBA that I know of.
我不熟悉 VBA for Access,但我认为最好的解决方案(也许最简单)是运行外部命令行 PGP 实用程序。
I am not familiar with VBA for Access, but i think that the best solution (perhaps easiest) would be run external command-line PGP utility.
您可以直接从 VBA 应用程序调用一个 DLL,而无需跨外部程序:CryptoCX< /a>. PGP 还有一个可以调用的 DLL。
There is a DLL you can call directly from your VBA application without having to span an external program: CryptoCX. PGP has also a DLL you can call.