C#转DELPHI 代码怎么转??

C#代码:


public static string Enc(string data)
{
System.Text.Encoding unicode = System.Text.Encoding.Unicode;
byte[] rgbKey = new byte[] {1,2,3,4,5,6,7,8};
byte[] rgbIV = new byte[] {1,2,3,4,5,6,7,8};
System.Security.Cryptography.DESCryptoServiceProvider dESCryptoServiceProvider = new System.Security.Cryptography.DESCryptoServiceProvider();
System.Security.Cryptography.ICryptoTransform cryptoTransform = dESCryptoServiceProvider.CreateEncryptor(rgbKey, rgbIV);
byte[] bytes = unicode.GetBytes(data);
byte[] array = cryptoTransform.TransformFinalBlock(bytes, 0, bytes.Length);
result = System.Convert.ToBase64String(array, 0, array.Length);
}

function Enc(data: string): string;
var
  unicode: System.Text.Encoding;
  rgbKey, rgbIV, bytes, array_: TBytes;
  dESCryptoServiceProvider: System.Security.Cryptography.DESCryptoServiceProvider;
  cryptoTransform: System.Security.Cryptography.ICryptoTransform;
begin
  unicode := System.Text.Encoding.Unicode;
  rgbKey := TBytes.Create(1, 2, 3, 4, 5, 6, 7, 8);
  rgbIV := TBytes.Create(1, 2, 3, 4, 5, 6, 7, 8);
  dESCryptoServiceProvider := System.Security.Cryptography.DESCryptoServiceProvider.Create;
  cryptoTransform := dESCryptoServiceProvider.CreateEncryptor(rgbKey, rgbIV);
  bytes := unicode.GetBytes(data);
  SetLength(array_, Length(bytes));
  cryptoTransform.TransformFinalBlock(bytes[0], 0, Length(bytes), array_[0], 0);
  Result := System.Convert.ToBase64String(array_);
end;