Einzelnen Beitrag anzeigen

Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#6

AW: Dec 5.2 decodiert nicht richtig (Einstellungen)

  Alt 3. Okt 2012, 00:45
Es scheint am MIME64 Encode & Decode zu liegen. Folgendes funktioniert:

Delphi-Quellcode:
function AESEncode(const Value: String; const Password: String): String;
var
  Cipher: TDECCipher;
  Salt,
  SessionKey: Binary;
begin
  Cipher := ValidCipher(TCipher_Rijndael).Create;
  try
    Salt := RandomBinary(16);
    SessionKey :=
      THash_SHA1.KDF2(Password, Salt, Cipher.Context.KeySize, TFormat_COPY);
    Cipher.Init(SessionKey);
    SetLength(Result, Length(Value));
    Cipher.Encode(Value[1], Result[1], Length(Value) * SizeOf(Value[1]));
    // Result := ValidFormat(TFormat_MIME64).Encode(Salt + Result);
    Result := Salt + Result;
    Cipher.Done;
  finally
    Cipher.Free;
  end;
end;

function AESDecode(const Value: String; const Password: String): String;
var
  Cipher: TDECCipher;
  Salt,
  SessionKey: Binary;
begin
  // Result := ValidFormat(TFormat_MIME64).Decode(Value);
  Result := Value;
  Cipher := ValidCipher(TCipher_Rijndael).Create;
  try
    Salt := Copy(Result, 1, 16);
    SessionKey :=
      THash_SHA1.KDF2(Password, Salt, Cipher.Context.KeySize, TFormat_COPY);
    Cipher.Init(SessionKey);
    Delete(Result, 1, 16);
    Cipher.Decode(Result[1], Result[1], Length(Result) * SizeOf(Result[1]));
    Cipher.Done;
  finally
    Cipher.Free;
  end;
end;
Kommentiere ich jeweils die MIMI64 Zeilen wieder ein, kommt nur noch Murks raus.
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)
  Mit Zitat antworten Zitat