unit decode;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdIOHandler, IdIOHandlerSocket,
IdSSLOpenSSL, StdCtrls, IdCoder, IdCoder3to4, IdCoderMIME, opensslutils,
libeay32;
type
TForm1 =
class(TForm)
ssl: TIdSSLIOHandlerSocket;
Button1: TButton;
.
.
.
private
{ Private-Deklarationen }
public
crypt, decrypt, decryptRAW :
string;
{ Public-Deklarationen }
end;
var
Form1: TForm1;
code: tstrings;
implementation uses dateutils, XSBuiltins;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var cer : TX509Certificate;
pk : pEVP_PKEY;
pr : pRSA;
l, padding : integer;
p :
array[1..50000]
of byte;
t,u :
string;
dt : tdatetime;
dt2 : txscustomdatetime;
i,j : integer;
begin
pk :=
nil;
pr :=
nil;
decrypt := '
nix';
padding := 1;
// PADDING constants RSA_PKCS1_PADDING = 1;
cer := TX509Certificate.create;
l := 0;
cer.loadfromfile('
cert.cer',DER);
pk := X509_get_pubkey(cer.cert);
setlength(decrypt,256);
move(pk.pkey.rsa^,decrypt[1],256);
l := RSA_public_decrypt(length(crypt), @crypt[1], @p[1], pk.pkey.rsa,padding);
setlength(decrypt,l);
move(p[1],decrypt[1],l);
decryptRAW := decrypt;
decrypt := reformat(decrypt);
memo2.text := decrypt;
end;
end.