我需要一個組件或庫(儘可能簡單,沒有DLL會很好)來加密文本,使用公鑰解密另一個文本由OpenSSL生成。需要一個Delphi組件/庫,允許我使用RSA加密/解密一些文本
我以爲我會使用LockBox(新版本,v3),但根據其他用戶在這裏它不如舊版本,更重要的是,不能使用其他庫中的密鑰。 (請參閱OpenSSL's PEM file and Lockbox3 interoperability)
我正在使用Delphi 7.有什麼建議嗎?
我需要一個組件或庫(儘可能簡單,沒有DLL會很好)來加密文本,使用公鑰解密另一個文本由OpenSSL生成。需要一個Delphi組件/庫,允許我使用RSA加密/解密一些文本
我以爲我會使用LockBox(新版本,v3),但根據其他用戶在這裏它不如舊版本,更重要的是,不能使用其他庫中的密鑰。 (請參閱OpenSSL's PEM file and Lockbox3 interoperability)
我正在使用Delphi 7.有什麼建議嗎?
這裏是一個手動,如何從OpenSSL的導入到的libeay32.dll德爾福:
http://www.disi.unige.it/person/FerranteM/delphiopenssl/
他們有文件加密/解密使用RSA:
http://www.disi.unige.it/person/FerranteM/delphiopenssl/RSAEncrypt.html
我們SecureBlackbox會做這項工作。 Delphi 7支持。也支持PEM格式的證書和密鑰(如果您在PEM中編碼了原始RSA密鑰,則需要編寫幾行代碼才能打開它,並通過一次函數調用從PEM加載X.509證書) 。
我們在Delphi 2010中使用Lockbox 2,它工作的很好。我想這也應該用Delphi 7在這裏工作是一個代碼示例:
unit LBRSA;
interface
uses
LbCipher,
LbRSA,
LbString,
LbUtils;
function DecryptRSA(const CipherText: String): String; overload; overload;
function DecryptRSA(const CipherText, Exponent, Modulus: String): String; overload;
implemention
function EncryptRSA(const ClearText, Exponent, Modulus: String): String;
var
RSA: TLbRSA;
begin
RSA := TLbRSA.Create(nil);
try
RSA.PublicKey.ExponentAsString := Exponent;
RSA.PublicKey.ModulusAsString := Modulus;
Result := RSA.EncryptStringW(ClearText);
finally
FreeAndNil(RSA);
end;
end;
function DecryptRSA(const CipherText, Exponent, Modulus: String): String;
var
RSA: TLbRSA;
begin
RSA := TLbRSA.Create(nil);
try
RSA.PrivateKey.ExponentAsString := Exponent;
RSA.PrivateKey.ModulusAsString := Modulus;
Result := RSA.DecryptStringW(CipherText);
finally
FreeAndNil(RSA);
end;
end;
end.
的Lockbox包括演示應用程序,讓您生成公鑰和私鑰。
爲什麼「沒有DLL」?使用openssl的DLL可以輕鬆地爲您提供openssl的互操作性。您可以將dll打包到您的應用程序的安裝程序中。 – osgx