[Delphi net] Encrypt/Decrypt

0

Pisałem na tym na inny forum lecz nie dostałem odpowiedzi więc postanowiłem tu napisać :)

Czy ktoś wie jak przerobić ten kod:

type
  Bytes = array of Byte;

function Encrypt(Buffer, Key, IV: Bytes): Bytes;
var
  Encryptor: ICryptoTransform;
  ST: MemoryStream;
  Encrypt: CryptoStream;
  FAlgorythm: RijndaelManaged;
begin
  
  if (IV = '') or (Key = '') then
  begin
	Result := Buffer;
	Exit;
  end;

  FAlgorythm := RijndaelManaged.Create;
  FAlgorythm.IV := IV;
  FAlgorythm.Key := Key;
  FAlgorythm.Mode := CipherMode.CBC;
  FAlgorythm.Padding := PaddingMode.Zeros;
  Encryptor := FAlgorythm.CreateEncryptor;

 
  ST := MemoryStream.Create;
  Encrypt := CryptoStream.Create(ST, Encryptor, CryptoStreamMode.Write);

  Encrypt.Write(Buffer, 0, Length(Buffer));
  Encrypt.FlushFinalBlock;

  Result := ST.ToArray;
end;

function Decrypt(Buffer, Key, IV: Bytes): Bytes;
var
  Decryptor: ICryptoTransform;
  ST: MemoryStream;
  Decrypt: CryptoStream;
  FAlgorythm: RijndaelManaged;
begin
  if (IV = '') or (Key = '') then
  begin
	Result := Buffer;
	Exit;
  end;

  FAlgorythm := RijndaelManaged.Create;
  FAlgorythm.IV := IV;
  FAlgorythm.Key := Key;
  FAlgorythm.Mode := CipherMode.CBC;
  FAlgorythm.Padding := PaddingMode.Zeros;

  Decryptor := FAlgorythm.CreateDecryptor;

  ST := MemoryStream.Create(Buffer);
  Decrypt := CryptoStream.Create(ST, Decryptor, CryptoStreamMode.Read);

  SetLength(Result, ST.Length);

  Decrypt.Read(Result, 0, ST.Length);
end;

tak żeby kodował i rozkodowywał tekst w stringu?? (.net)
Lub jak przerobić TO!!! z C# do delphi.NET

0

Musi być ten algorytm? Mam fajnego Vigener'a

0
Oleksy_Adam napisał(a)

Musi być ten algorytm? Mam fajnego Vigener'a

nie musi byc byle by działał w net :) z gory thx :)
Niestety ten algorytm raczej nie działa pod NET ma ktoś jakieś inne pomysły?

1 użytkowników online, w tym zalogowanych: 0, gości: 1