我已从 GitHub 下载 TurboPack LockBox3 并将其安装到 RAD Studio XE6 中。如果我将必要的组件放在表单上,那么一切正常。但是,我需要能够在运行时调用我的加密例程,因此出于测试目的创建了一个带有几个编辑框和一个按钮的表单。按钮事件处理程序包含以下内容:
Codec1 := TCodec.Create(nil);
Codec1.CryptoLibrary := TCryptographicLibrary.Create(Codec1);
Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
Codec1.cipher := 'native.AES-256';
Codec1.ChainMode := uTPLb_Constants.CBC_ProgId;
Codec1.Password := Password;
tmp := LBEdit1.Text; // fetch the plaintext from form
if tmp <> '' then
begin
Try
Codec1.Reset;
Codec1.EncryptString(tmp, ciphertext, TEncoding.UTF8);
Edit1.Text := string(ciphertext); // display the ciphertext
Finally
Codec1.Free;
End;
end;
它编译得很好,但在运行时我收到一条错误消息“TSimpleCodec.Begin_EncryptMemory - 算法未设置。” 我假设我没有正确初始化某些东西但看不到什么。谁能指出我正确的方向?