我刚刚发现密码箱 3.6.0 应该支持 Android。但是,当我查看调色板时,我发现编解码器仅支持 win32 和 win64。
我怎样才能让它也适用于我的 android 应用程序?
我使用的是 Delphi XE7,并且已经按照包中提供的安装说明进行操作。对于 Windows 应用程序,它工作得很好。
我刚刚发现密码箱 3.6.0 应该支持 Android。但是,当我查看调色板时,我发现编解码器仅支持 win32 和 win64。
我怎样才能让它也适用于我的 android 应用程序?
我使用的是 Delphi XE7,并且已经按照包中提供的安装说明进行操作。对于 Windows 应用程序,它工作得很好。
你有两个选择:
您始终可以在运行时创建组件。网站上有一个关于如何做的例子,我在下面复制了这个例子的一个片段。只需将 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
属性声明了组件应该在哪些平台上显示,在调色板上。如果没有声明,我相信默认是pidWin32 or pidWin64
,但我不能指向任何官方文档来支持这一点。
save-all
在成功编译之前进行。转到 IDE 工具 | 选项并打开 Android 平台的库路径。确保此路径包含您放置 Android 案例的 dcu 文件的位置。例如,在我的安装中,它是...
C:\Dev\TPLB\work-products\ephemeral\dcu\XE6\Android
您应该实际检查此目录。例如,它应该有一个名为的文件TPLB3.AES.dcu
和另一个名为的文件TPLB3.AES.so
。