我会选择 OpenSSL。
PHP 似乎对它有很多支持,尽管我还没有真正尝试过:
例如手册 and 这里有一个例子.
使用我在这里多次提到的内容,只需做一些工作,就可以使 Delphi 与 OpenSSL 很好地配合使用:http://www.disi.unige.it/person/FerranteM/delphiopenssl/。该页面上也有一些很好的例子。并查看 Indy OpenSSL 导入。
不是特定的组件,但绝对免费、灵活,并且完全有可能向自己开枪,安全方面,在脚上:-)
EDIT:
对于 Delphi,我会考虑使用 EVP_Seal* 函数,您可以在以下位置找到我的精简版 libeay32.pas 文件:这个答案。您需要这个,因为 Indy 没有显示或实现很多/任何实际的 EVP_ 函数,因此您需要导入函数声明和一些其他例程。
For PHP 这个链接似乎是正确的对手。
作为奖励,这应该让您了解如何使用 EVP_Seal* 东西(未经测试):
function EVPSeal(ASource: TBytes; const APublicKey: PEVP_PKEY; out Key: TBytes; out IV: TBytes): TBytes;
var
cipher: PEVP_CIPHER;
ctx: EVP_CIPHER_CTX;
buf: TBytes;
block_size, buf_start, out_len, keysize: integer;
ek: array[0..0] of PByte;
ekl: array[0..0] of integer;
pubk: array[0..0] of PEVP_PKEY;
begin
keysize := EVP_PKEY_size(APublicKey);
cipher := EVP_aes_256_cbc;
SetLength(IV, EVP_MAX_IV_LENGTH);
SetLength(Key, keysize);
ek[0] := @Key[0];
pubk[0] := APublicKey;
buf_start := 0;
EVP_CIPHER_CTX_init(@ctx);
try
EVP_SealInit(@ctx, cipher, @ek[0], @ekl, @IV[0], @pubk[0], 1);
block_size := EVP_CIPHER_CTX_block_size(@ctx);
SetLength(buf, Length(ASource) + block_size);
SetLength(Key, ekl[0]);
EVP_SealUpdate(@ctx, @buf[buf_start], out_len, @ASource[0], Length(ASource));
Inc(buf_start, out_len);
EVP_SealFinal(@ctx, @buf[buf_start], out_len);
Inc(buf_start, out_len);
SetLength(buf, buf_start);
result := buf;
finally
EVP_CIPHER_CTX_cleanup(@ctx);
end;
end;