将TurboPower Lockbox 2转换为LockBox 3 [英] Converting TurboPower Lockbox 2 to LockBox 3

查看:202
本文介绍了将TurboPower Lockbox 2转换为LockBox 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将一个项目(使用加密)从Delphi 6转换为XE。该项目使用的旧版Delphi加密纲要在XE中不起作用。因此,我想从该组件集交换到LockBox。 LockBox有两个版本-2和3。在Delphi 6中使用LockBox2没有问题。虽然我会在XE中使用LockBox3,但是我遇到的问题是,当与...一起使用时,我无法获得相同的结果。 ExFile演示程序(来自LockBox2)。

I am currently in the process of converting a project (that uses encryption) from Delphi 6 to XE. This project uses the old Delphi Encryption Compendium which does not work in XE. So I figured that I would swap from that component set to LockBox. There are two versions of LockBox - 2 and 3. I have no problems with using the LockBox2 in Delphi 6. I though that I would use LockBox3 in XE, but the problem that I have is that I cannot get the same results when used with ExFile demo program (from LockBox2).

在该演示中,我选择Blowfish算法将密码设置为 testkey(不带引号),程序将对文件进行加密。

In that demo I select the Blowfish algorithm set the password to 'testkey' without the quotes and the program will encrypt the file.

在Delphi XE中,我放入表格

In Delphi XE, I dropped onto the form

Codec1: TCodec;
CryptographicLibrary1: TCryptographicLibrary;

并将Codec1链接到CryptographicLibrary1,并在单击按钮时执行以下代码(在LockBox3上找到类似的代码...

and linked Codec1 to CryptographicLibrary1 and when clicking a button the following code is executed (found similar code on LockBox3 site for decrypting strings)....

  codec1.StreamCipherId := BlockCipher_ProgId;
  codec1.BlockCipherId := Blowfish_ProgId;
  codec1.ChainModeId := ECB_ProgId;
  codec1.Password := 'testkey';
  codec1.encryptFile('d:\tools\mingw\bin\md5.exe', 
   'd:\tools\mingw\bin\md5_xe_2.exe');

但是最终结果是输出文件的大小与LockBox2 ExFile演示的大小不同。

But the end result is that the output file has a different size to that from the LockBox2 ExFile demo.

所以我的问题是...。

So my questions are....


  1. 有什么我在上面的XE代码中做错了,所以我给LockBox2的ExFile演示结果不同?

  1. What have I done wrong in the XE code above such that I gives a different result to ExFile demo from LockBox2?

我应该在XE中使用LockBox2吗?

Should I just use LockBox2 within XE?

与2相关,是否有人在关注代码LockBox2(用于XE)?

Related to 2, is there someone looking after the code LockBox2 (for XE)?

任何帮助将不胜感激。

致谢,

推荐答案


  1. 用户 mj2008碰到了头。 Delphi 6使用ansistring作为字符串。 Delphi XE使用UTF-16LE。在屏幕上显示或从键盘输入的相同密码是完全不同的数据,因此自然而然地,结果也会有所不同。

关于预期的文件大小。 Blowfish是一个8字节(64位)的块模式密码。尽管其他链接模式将有所不同,但是ECB使用块填充来填充最后一个块。 TPLB3对ECB使用RFC1321填充方案,也就是说,它将消息填充为一个$ 80字节,后跟足够的零以得到整个块大小。 TPLB2使用另一种方案:用零填充直到最后一个字节,该字节设置为pack块中预填充的字节数。

About expected file sizes. Blowfish is an 8 byte (64 bit) block mode cipher. Although it will be different for other chaining modes, ECB uses block padding to pad out the last block. TPLB3 uses the RFC1321 padding scheme for ECB, which is to say it pads the message out with one $80 byte followed by enough zeroes to get a whole block size. TPLB2 uses a different scheme: It pads with zeroes until the last byte, which it sets to the number of pre-padded bytes in the pack block.

因此,如果您的纯文本文件的大小为X个字节,如果使用Blowfish / ECB加密,则密文大小Y应该为:

So if your plaintext file is Size X bytes, and if you encrypt with Blowfish/ECB, then the ciphertext size Y, should be:

Y = X + 8-(X mod 8)

Y = X + 8 - (X mod 8)

(有关更多详细信息,请参阅论坛主题: http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=154&topics_offset=2&ums_destrodmode=Post = 2

(Refer to forum thread for more detail: http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=154&topics_offset=2&topics_sort_mode=lastPost_desc&forumId=2)

* 2。需要说明的是,我对您的程序的目的和上下文一无所知,并且具体情况可能会影响此问题,因此我想对您的Delphi XE程序使用TurboPower LockBox 3。如果需要与旧的LB2密文互操作,则编写并执行一次转换程序,即可将LB2密文转换为LB3密文。然后丢弃LB2。

*2. With the caveat that I know nothing about the purpose and context of your program, and that specific circumstances may impact on this question, I would say use TurboPower LockBox 3 for your Delphi XE program. If you have a need to interoperate with old LB2 ciphertext, then write and execute once-off, a conversion program to convert LB2 ciphertext to LB3 ciphertext. Then discard LB2.

* 3。我将继续维护LB2,但仅会修复LB2中报告的主要缺陷,而不会修复LB2中的RSA组件。

*3. I continue to maintain LB2, but I will only fix reported major defects in LB2, and I will not fix the RSA component in LB2.

这篇关于将TurboPower Lockbox 2转换为LockBox 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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