Tbytes handling

Hello,

I have successfully added TMS Cryptrography component to the Scripter :
All using RTTI except for all overloaded methods like TAESEncryption.create (on some other methods) which can have 0 to 7 arguments :

  with Scripter.DefineClassByRTTI(TAESEncryption) do
  begin
    DefineMethod('Create',7,tkClass,TAESEncryption,__TAESEncryptionCreate,true,7,'AOwner: TComponent');
    DefineMethod('Decrypt',2,tkVariant,nil,__TAESEncryptionDecrypt,false,1,'s: string');
  end;

But some methods need uses Tbytes type arguments in Scripter, for example (extracted form TmsCryptography.pdf) :

var
   aes: TAESEncryption;
   conv: TConvert;
   str: string;
   b:Tbytes; // <= here
begin
   aes:= TAESEncryption.Create;
   conv:= TConvert.Create;
   try
      aes.AType := atcbc;
      aes.KeyLength := kl128;
      aes.OutputFormat := hexa;
      aes.Key := conv.TBytesToString(b);  // <= here
      aes.IVMode := rand;
      aes.PaddingMode := PKCS7;
      aes.Unicode := yesUni;
      str := AES.Encrypt('test');
   Finally
      aes.Free;
      conv.Free;
   end;
end;

That's a bit complicated to handle TBytes in scripter.
Could you provide a code source to handle correctly the TBytes type in scripter ?

TBytes is not a type supported in Scripter.

What you can do is to implement your own converters from an array of Variant to TBytes inside the Delphi code that implements the scripter wrapper.

Or maybe even better - that depends on your application and users - maybe allow use of base64-encoded strings, so that from script the bytes are always treated as base64. Then you implement conversions to/from base64 and TBytes.