我刚刚发现lockbox 3.6.0应该支持Android。但是当我查看我的调色板时,我发现编解码器只支持win32和win64。
我怎样才能使它适用于我的Android应用程序呢?
我正在使用Delphi XE7并且已经按照包中提供的安装说明进行操作。对于Windows应用程序,它工作正常。
答案 0 :(得分: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;
需要进行一些调整才能将组件放到Android的调色板上。这将在下一版本的TPLockbox 3中发布,但是现在,这是程序......
vcl
,vclimg
和dbrtl
。libTP_LockBox3_XE7.so
,其中XE7
是编译器版本的位置标记。前言
两个组件(TCodec和TCryptographicLibrary)的声明[ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator or pidiOSDevice or pidAndroid)]
TCodec = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher,
{ etc. }
这是整个事情的关键。 ComponentPlatformsAttribute
attribute在调色板上声明组件应显示的平台。如果没有声明,我相信默认值是pidWin32 or pidWin64
,但我不能指出任何官方文档来支持这一点。
save-all
才能成功编译。转到IDE工具|选项并打开Android平台的库路径。确保此路径包含您为Android案例放置dcu文件的位置。例如,在我的安装上它是......
C:\开发\ TPLB \工作产品\短暂\ DCU \ XE6 \的Android
您应该检查此目录。它应该有一个名为TPLB3.AES.dcu
的文件和另一个名为TPLB3.AES.so
的文件。