TurboPower组件是最受欢迎的商业组件库之一,并且在开源时仍被许多Delphi开发人员使用.我没想单独询问,而是想问一个关于每个组件的XE2兼容性状态的问题.TurboPower Abbrevia,AsyncPro和LockBox是主要的.
兼容性包括平台支持:XE2 Win32,Win64,Mac OS X.(我怀疑Async Pro会不会用于Mac OS X,但至少可能是XE2 Win32.)
我的应用程序通过Internet发送加密文件,我需要能够执行以下操作:
听起来很简单,但我找不到任何可靠的代码/组件,我找到了这些组件:
DCPcrypt.这就是我现在正在开发中使用但似乎不支持基于密钥对的加密(RSA?)
GnuPgp(GPL)所以我不能在我的商业应用程序上使用它.
TurboPower LockBox 3:支持密钥对加密,但非常神秘(没有文档AFAIK),似乎不支持文件加密.
我的问题是:是否存在安全/可靠的加密组件:
问题
由于这个问题,我不得不将我的 RoR 应用程序升级到 Rails 7 。进行此升级时,由于 Rails 使用本机解密尝试解密字段,因此无法再读取使用Lockbox gem加密的 db 列。我在 GitHub 上将它作为一个问题发布,但我也想知道是否有其他人有解决方案将数据从一种加密格式迁移到新的本机加密中,该加密将随 Rails 7.0 一起提供(目前 Rails 的稳定版本是6.1.4 和 Rails 7.0.alpha 在 GitHub 的主分支上)
代码
应用程序/模型/journal_entry.rb
class JournalEntry < ApplicationRecord
belongs_to :prayer_journal
encrypts :content
validates :content, presence: true
end
Run Code Online (Sandbox Code Playgroud)
数据库/模式.rb
create_table "journal_entries", force: :cascade do |t|
t.bigint "prayer_journal_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.text "content_ciphertext"
t.index ["prayer_journal_id"], name: "index_journal_entries_on_prayer_journal_id"
end
Run Code Online (Sandbox Code Playgroud)
第一个日志条目的控制台输出
#<JournalEntry:0x00007f95364745c8 …Run Code Online (Sandbox Code Playgroud) 我想用AES-128用密码加密Delphi中的字符串.我想将它上传到我的服务器,并能够在C#中使用相同的密码进行解密.
在Delphi中,我使用的是TurboPower LockBox 3:
function EncryptText_AES_128(input: string; password: string): string;
var
Codec: TCodec;
CipherText: AnsiString;
begin
Codec := TCodec.Create(nil);
try
Codec.CryptoLibrary := TCryptographicLibrary.Create(Codec);
//
Codec.StreamCipherId := BlockCipher_ProgID;
Codec.BlockCipherId := Format(AES_ProgId, [128]);
Codec.ChainModeId := CBC_ProgId;
//
Codec.Password := Password;
Codec.EncryptString(input, CipherText);
//
Result := string(CipherText);
finally
Codec.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
如何在C#中解密生成的字符串? 我可以改变Delphi代码.什么都没有生产.我甚至没有坚持使用LockBox.但是,我想避免将它放在P/Invoke的DLL中.
(我的例子表明我的加密序列本身就是一个字符串.这对我来说不是必需的.字节流很好.)
我用Delphi XE10尝试使用lockbox3.我想加密用户的输入字符串,并将其与验证值进行比较.但每次相同的输入字符串给出不同的加密结果.请问我的错是什么?
这里是给出此错误的示例代码
<UNIT CODE START>
unit Unit21;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, TPLB3.Codec, TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary,
Vcl.StdCtrls;
type
TForm21 = class(TForm)
Button1: TButton;
CryptographicLibrary1: TCryptographicLibrary;
Codec1: TCodec;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form21: TForm21;
implementation
{$R *.dfm}
procedure TForm21.Button1Click(Sender: TObject);
var s0,s1 : string;
begin
codec1.Password := 'ou[asdl[kn';
s0 := 'asdfghjkl';
codec1.EncryptString(s0,s1);
label1.caption := s1;
end;
end.
<UNIT CODE END>
<FORM CODE …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在PHP中为CBC实现Ciphertext Stealing(CTS)。
在下面引用两个链接
如何在PHP中使用AES CBC + CTS(密文窃取)模式加密/解密数据?
和
http://en.wikipedia.org/wiki/Ciphertext_stealing
我对XOR的最后一步和最简单的步骤感到困惑和困惑。我知道这很愚蠢,但是尝试了所有组合之后,我不知道我在想什么。代码如下。
// 1. Decrypt the second to last ciphertext block, using zeros as IV.
$second_to_last_cipher_block = substr($cipher_text, strlen($cipher_text) - 32, 16);
$second_to_last_plain = @mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $second_to_last_cipher_block, MCRYPT_MODE_CBC);
// 2. Pad the ciphertext to the nearest multiple of the block size using the last B-M
// bits of block cipher decryption of the second-to-last ciphertext block.
$n = 16 - (strlen($cipher_text) % 16);
$cipher_text .= substr($second_to_last_plain, -$n);
// 3. Swap the last …Run Code Online (Sandbox Code Playgroud) 我在使用 lockbox3 和 PHP mcrypt 时遇到了麻烦。我无法将 IV 传递给 PHP。德尔福代码:
var
Codec: TCodec;
CL: TCryptographicLibrary;
PlainStream: TStringStream;
CipherStream: TMemoryStream;
begin
PlainStream := TStringStream.Create(Edit1.Text);
CipherStream := TMemoryStream.Create;
CL := TCryptographicLibrary.Create(nil);
Codec := TCodec.Create(nil);
Codec.CryptoLibrary := CL;
Codec.ChainModeId := uTPLb_Constants.CBC_ProgId;
Codec.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
Codec.BlockCipherId := Format(uTPLb_Constants.AES_ProgId, [256]);
Codec.Password := Edit3.Text;
Codec.EncryptStream(PlainStream, CipherStream);
Codec.Burn;
Memo1.Text := Stream_to_Base64(CipherStream);
Memo2.Clear;
Memo2.Lines.Add(Format('Size: %d bytes', [CipherStream.Size]));
Memo2.Lines.Add(Format('Original size: %d bytes', [PlainStream.Size]));
Codec.Free;
CL.Free;
CipherStream.Free;
PlainStream.Free;
Run Code Online (Sandbox Code Playgroud)
和PHP 代码:
$ciphertext = base64_decode("zA/eeF+WFVMDsZ7+iA==");
$iv = substr($ciphertext, 0, …Run Code Online (Sandbox Code Playgroud) 这是我第一次安装 Lockbox 的库。我从sourceforge下载了3.4.3版本,并拥有Delphi 7。第一步是让这个傻瓜在Delphi 7下编译,这真是太糟糕了。我确实希望这些组件在安装后更容易使用。
好的。我有一个看起来像这样的单位。
unit uTPLb_StrUtils;
interface
uses
SysUtils, uTPLb_D7Compatibility;
function AnsiBytesOf(const S: string): TBytes;
implementation
function AnsiBytesOf(const S: string): TBytes;
begin
//compiler chokes here
**Result := TEncoding.ANSI.GetBytes(S);**
end;
end.
Run Code Online (Sandbox Code Playgroud)
顺便说一句,兼容性单元将 TBytes 定义为 TBytes = 字节打包数组;
Delphi 7 对 TEncoding 感到窒息,因为它只存在于 D2009+ 中。我用什么来替换这个功能?
我的Delphi应用程序使用TurboPower LockBox 3使用AES 256加密明文信息.我现在想用PHP解密这些信息.但TurboPower LockBox 3存在一些互操作性问题.
有关详细信息,请查看LockBox 3作者的帖子:
http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=363&topics_offset=1
和Stackoverflow上的类似帖子
在LockBox 3中,在加密期间,您设置密码.然后将此密码用作种子以生成密钥和iv.那么有没有人能够模仿PHP方面的密钥生成方法?或者有什么方法可以让LockBox 3生成Key/IV并将其放入我的PHP代码中以便解密文件?
我大约一周前已经下载了Lockbox3,但我无法使用它,并且我无法理解该演示,因为它很复杂,无法从中获取所需的代码,我想使用Lockbox 3 AES- 256个加密可在Delphi中加密字符串。
lockbox-3 ×10
delphi ×8
encryption ×5
aes ×4
cryptography ×3
php ×3
turbopower ×3
c# ×1
cbc-mode ×1
rsa ×1
security ×1