I need a Delphi component / library that allows me to encrypt / decrypt some text using RSA

I need a component or library (as far as possible, and there will be no DLL files) to encrypt the text, decrypt the other using the public keys created by OpenSSL.

I thought I would use LockBox (new version, v3), but according to other users, here it is not as good as the old version, and, more importantly, cannot use keys from other libraries. (see OpenSSL PEM file and Lockbox3 compatibility )

I am using Delphi 7. Any suggestions?

+5
source share
3 answers

Lockbox 2 Delphi 2010, . , 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 , .

+6

SecureBlackbox . Delphi 7. PEM ( RSA, PEM, , , X.509 PEM ).

+4

All Articles