适用于Android的Lockbox 3,XE7无法正常工作

时间:2015-01-03 14:07:19

标签: delphi firemonkey delphi-xe7 lockbox-3

我刚刚发现lockbox 3.6.0应该支持Android。但是当我查看我的调色板时,我发现编解码器只支持win32和win64。

我怎样才能使它适用于我的Android应用程序呢?

我正在使用Delphi XE7并且已经按照包中提供的安装说明进行操作。对于Windows应用程序,它工作正常。

1 个答案:

答案 0 :(得分:1)

您有两种选择:

(1)运行时间

您始终可以在运行时创建组件。有一个example on the website如何做到这一点,我复制下面这个例子的片段。只需用适当的东西替换ShowMessage()函数......

procedure EncryptAStream( Plaintext, Ciphertext: TStream);
var
 Codec1: TCodec;
 CryptographicLibrary1: TCryptographicLibrary;
begin
ShowMessage( 'Demonstration of How to Encrypt a Stream with TurboPower LockBox 3.');
Codec1 := TCodec.Create( nil);
CryptographicLibrary1 := TCryptographicLibrary.Create( nil);
Codec1.CryptoLibrary  := CryptographicLibrary1;
Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
Codec1.BlockCipherId  := 'native.AES-256';
Codec1.ChainModeId    := uTPLb_Constants.CBC_ProgId;
Codec1.Password := 'my utf-16le password';

// Codec1.Reset;  Reset if you are continuing from a previous encryption operation.
Codec1.EncryptStream( Plaintext, Ciphertext);
// Codec1.Burn;   Burn if you need to purge memory of sensitive data.

Ciphertext.Position := 0;

ShowMessageFmt(
 'The ciphertext for AES-256 with CBC chaining'#13#10 +
 ' of plaintext ''banana'' (UTF-8 encoding),'#13#10 +
 ' and password ''my utf-16le password'' (UTF-16LE encoding),'#13#10 +
 ' prepended by 64 bit nonce, (being the IV),'#13#10 +
 ' and rendered for display in base64 is ...'#13#10 +
 '%s', [Stream_to_Base64( Ciphertext)]);

Codec1.Free;
CryptographicLibrary1.Free;
end;

(2)设计时

需要进行一些调整才能将组件放到Android的调色板上。这将在下一版本的TPLockbox 3中发布,但是现在,这是程序......

  1. 从TPLB3运行时要求中删除vclvclimgdbrtl
  2. 对于运行时包,添加Android目标平台,并使其成为活动平台。但当然,不要将此平台添加到设计时包中。
  3. 运行时的二进制产品应命名为libTP_LockBox3_XE7.so,其中XE7是编译器版本的位置标记。
  4. 前言

    两个组件(TCodec和TCryptographicLibrary)的声明
    [ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator or pidiOSDevice or pidAndroid)]
    TCodec = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher,
                     { etc. }
    
  5. 这是整个事情的关键。 ComponentPlatformsAttribute attribute在调色板上声明组件应显示的平台。如果没有声明,我相信默认值是pidWin32 or pidWin64,但我不能指出任何官方文档来支持这一点。

    1. 重新编译运行时包。请记住,如果您正在使用MS-BUILD进行编译,在某些编译器版本上,您需要save-all才能成功编译。
    2. 转到IDE工具|选项并打开Android平台的库路径。确保此路径包含您为Android案例放置dcu文件的位置。例如,在我的安装上它是......

      C:\开发\ TPLB \工作产品\短暂\ DCU \ XE6 \的Android

    3. 您应该检查此目录。它应该有一个名为TPLB3.AES.dcu的文件和另一个名为TPLB3.AES.so的文件。

      1. 重新编译并重新安装设计时包
      2. 打开您的移动项目。在Android表单上为TCodec和TCryptographicLibrary拍摄设计时组件。继续执行Windows应用程序。