Einzelnen Beitrag anzeigen

Benutzerbild von TheGame1492
TheGame1492

Registriert seit: 31. Jul 2004
Ort: Berlin
84 Beiträge
 
Delphi XE2 Professional
 
#7

AW: umwandlung von Delphi 7 in 2010 macht probs

  Alt 16. Jun 2010, 19:53
D2010:

Delphi-Quellcode:
  function EncryptIrcBlowfish(dText, key: ansistring): pansistring; stdcall; external 'project1.dllname 'EncryptIrcBlowfish';
  function DecryptIrcBlowfish(eText, key: ansistring): ansistring; stdcall; external 'project1.dllname 'DecryptIrcBlowfish';

var
  str, key, strDecrypted, strEncrypted: ansistring;
  pstrEncrypted: pansistring;
begin
  try
    str := 't2e3s4t5t6e7st';
    key := '123';
    writeln('----');
    pstrEncrypted := EncryptIrcBlowfish( str, key );
    strEncrypted := AnsiString(pstrEncrypted);
    writeln('Encrypted: '+strEncrypted);
    strDecrypted := DecryptIrcBlowfish( strEncrypted, key );
    writeln('DEcrypted: ' +strDecrypted);
D7 DLL:
Delphi-Quellcode:
function EncryptIrcBlowfish(dText, key: ansistring): pansistring; stdcall;
var temp, eText: ansistring;
    i: Integer;
    mykey: ansistring;
begin
  eText := '';
  if(dText<>'') then
  begin
    temp := '';

    if (length(dText) mod 8 > 0) then
      for i:= 1 to 8 - (length(dText) mod 8) do
        dText:= dText+ #0;

    temp := '';

    mykey:= set_key(key);
    for i:= 1 to length(dText) div 8 do
    begin
      temp:= Copy(dText, 1+(i-1)*8,8);
      SetLength(temp, 8);
      madcrypt.Encrypt(PChar(temp), 8, mykey);
      eText := eText + bytetoB64(temp);
    end;
  end;
  Result:= pansistring(eText);
end;


function DecryptIrcBlowfish(eText, key: ansistring): ansistring; stdcall;
var temp, dText: ansistring;
    i : Integer;
    mykey: ansistring;
begin
  mykey:= set_key(key);
  for i:= 1 to length(eText) div 12 do
  begin
     temp := B64tobyte(Copy(eText,1+(i-1)*12,12));
     SetLength(temp, 8);
     madcrypt.Decrypt(PChar(temp), 8, mykey);
     dText := dtext + temp;
  end;

  Result:= dText;
end;

exports
  EncryptIrcBlowfish,
  DecryptIrcBlowfish;

Geändert von mkinzler (16. Jun 2010 um 19:56 Uhr) Grund: Code-Tags durch Delphi-Tags ersetzt
  Mit Zitat antworten Zitat