NAV 2013 MD5 Hash generator

MarijnMarijn Member Posts: 69
edited 2014-07-19 in NAV Three Tier
Hello,

The goold old Navision Attain Hash 1.0.HashCalculator automation does not seem to work in NAV 2013. In 2009 and earlier NAV versions it works fine. But in 2013, when compiling the object, it throws an error: You cannot create an Automation Hash on Microsoft Dynamics NAV Server. You must create it on a client computer.

This message puzzles me and I have no idea how I would generate a hash in NAV 2013. If someonse can point me in the right direction I would be very grateful.

Comments

  • KishormKishorm Member Posts: 921
    Use the 2nd parameter of the CREATE() function - pass TRUE and this will create the automation object on the client PC instead of the service tier server.
  • MarijnMarijn Member Posts: 69
    Thank you for your answer.

    NAV 2013 does not let me save the codeunit. Compiling using F11 does not throw an error, but saving is not allowed for some reason. I am trying something like this:

    CREATE(Hash, FALSE, FALSE);
    HashString := Hash.CalculateMD5(InputString);
    CLEAR(Hash);
    EXIT(HashString);

    (Hash: Navision Attain Hash 1.0.HashCalculator)

    According to the documentation, the ClientSide boolean would be the third parameter, but I tried all combinations of TRUE and FALSE for the second and third parameters but NAV never allows saving the object. It makes me wonder whether this automation can still be used in 2013. It seems odd that something like generating a text string needs to be done clientside.
  • MarijnMarijn Member Posts: 69
    Ok. Creating a hash now works in NAV 2013. Not sure where I messed up though.

    CREATE(Hash, TRUE, TRUE);
    HashString := Hash.CalculateMD5(String);
    CLEAR(Hash);
    EXIT(HashString);
  • KishormKishorm Member Posts: 921
    Yes, should be third parameter - didn't have NAV in front of me and my memory is not what it used to be ;-)
  • krikikriki Member, Moderator Posts: 9,112
    BTW: you should stop using automation and start using .NET. NAV2013 servicetier has some problems with 32-bit automation because it is a 64-bit application.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • PtaPta Member Posts: 25
    Does anybody know if there is a dot net assembly availible that I can use?
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Use 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.System.Web.Security.FormsAuthentication
    MESSAGE(MD5.HashPasswordForStoringInConfigFile('a','MD5'));
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • PtaPta Member Posts: 25
    Thanks a lot!
  • vremeni4vremeni4 Member Posts: 323
    Hi,

    I would also recommend this one as you can create MD5 hash for a file or a BLOB field.
    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('');
    


    I hope this helps someone.
    Thanks.
Sign In or Register to comment.