Byte.Length

imclever1205imclever1205 Member Posts: 94
Hi Guys ,

I am writing a function to calculate MD5 Hash in Navision.
I am taking a .net code as reference but I got stuck on a code which goes like

byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
then
data.Length

So I declared a variable called VarByte in Nav of Datatype DotNet and Subtype System.Byte.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' then System.Byte

My problem is that when I do VarByte .Length is does not recognise this property .

Even I set the dimension on the variable it gives me the same error.

If I try to declare my variable as byte directly ,it does not accept the previous code I wrote i.e
VarByte:=md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); It throws an error of Invalid Datatype From Byte to DotNet

Does anyone know how to get the length of a byte variable in Navision ?

Comments

  • vremeni4vremeni4 Member Posts: 323
    Hi

    Try This code.
    Name   DataType   Subtype   Length
    MD5   DotNet   System.Security.Cryptography.MD5.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'   
    BTcon   DotNet   System.BitConverter.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'   
    SInStream   InStream      
    HashKey   Text      50
    
    GetMD5Hash(SEntry : Record "S Entry") : Text[50]
    SEntry.CALCFIELDS(SBLOB);
    IF SEntry.SBLOB.HASVALUE THEN BEGIN
      SEntry.SBLOB.CREATEINSTREAM(SInStream);
      MD5:=MD5.Create();
      MD5.ComputeHash(SInStream);
      HashKey:= BTcon.ToString(MD5.ComputeHash(SInStream));
      HashKey:=DELCHR(HashKey, '=', '-');
      EXIT(HashKey);
    END ELSE
      EXIT('');
    
  • imclever1205imclever1205 Member Posts: 94
    thanks buddy
  • smagismagi Member Posts: 3
    Is System.Security.Cryptography.MD5.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' part of Net Framework 4.6? I cannot find it with framework 4.5.
Sign In or Register to comment.