Einzelnen Beitrag anzeigen

Kytrix

Registriert seit: 26. Nov 2007
54 Beiträge
 
#7

AW: Decrypten von Daten in TStringList fehlerhaft

  Alt 25. Aug 2012, 17:24
Delphi-Quellcode:
function HexStringToStr(s : string):string;
begin
  if s = 'then
    Result := ''
  else
  begin
    if Odd(length(s)) then
      s := '0'+s;
    SetLength(Result, Length(s) div 2);
    HexToBin(Pchar(s), PChar(Result), Length(Result));
  end;
end;

procedure TfMain.BtOpenClick(Sender: TObject);
Var w:Word;
    Crypt: String;
begin
  w:=16518;

  OpenDialog1.Execute;
  RegInfo.LoadFromFile(OpenDialog1.FileName);
  Crypt:=RegInfo.Text;
  EdShowInfo.Text:=Decrypt(HexStringToStr(Crypt),w);// load decryptet from Base16
end;
und

Delphi-Quellcode:
function StrToHexString(const s : string):string;
begin
  if s = 'then
    Result := ''
  else
  begin
    SetLength(Result, Length(s)*2);
    BinToHex(PChar(s), PChar(Result), Length(s));
  end;
end;

procedure TfMain.SaveEncrypted(Sender: TObject);
Var InformationText: TStringList;
  w:Word;
  Crypt:String;
begin
  fMain.Visible:=false;
  w:= 16518;
  InformationText:=TstringList.Create();
  Crypt:=StrToHexString(Encrypt(CreateRegInfo,w)); // Save encrypted as Base16
  InformationText.Add(Crypt);
  InformationText.SaveToFile(ExtractFilePath(ParamStr(0))+'reg_info.dat');

end;
jetzt bekomme ich einen halb richtig entschlüsselten string

edit: irgendwo ist noch der wurm drinne ^^

danke für die antworten

Geändert von Kytrix (25. Aug 2012 um 17:26 Uhr)
  Mit Zitat antworten Zitat