Hello,
I am using the HashCalculator of the automation of Navision Attain. But how can I get the MD5 of the data inside the file? The data exceeded the limitation 1024 of text variable. So i cannot just put it in a variable then past it to the automation. Please suggest me what to do.
Thanks in advance.
Navision noob....
0
Comments
Depends what you're going to achieve.
If you only want to hash your file for internal use, without any compatibility with external tools/systems (for example 2 NAV installations interchanging some data, and hash is used solely for checking if the data was not changed in-between), then you can write some functions based on CalculateMD5 function.
The algorithm could be for example:
1 Take 512 bytes of file
2. Hash it
3. Take half (512) bytes of hashed output
4. Take next 512 bytes of file
5. Join them into 1024 bytes text
6. Hash it
7. If not end of file goto 3
8. Use last hash output as your result.
You will get your entire file hashed, no matter how long it will be. Hash generated will not be MD5 hash, but strong enough to use as a digital signature of file
If you need to hash your data file and generated hash have to be MD5 compatible (for example in order to check it in some external system) then you can do nothing with with HashCalculator I'm afraid.
Find and download some simple command line utility, calculating MD5 hash from file passed in command line parameters (there are lots of such utilities on the Internet), call it from NAV using SHELL function, and read output (stored in another file) into NAV.
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Many thanks for your response. I really appreciate it. Actually, the scenario is this. I am receiving files and processing it to save its data contents in the database. After saving, I will also save the details of the file such as (filename and MD5 of its data contents), this is to compare from other files that i will be processing. So for example, I have the files "MyFile1.txt" and "MyFile2.txt" but its data contents are similar. From my requirement, I have to detect this files and prompt an error.
You mentioned that there are some application in the internet. Can you give samples? Pleassseee....
Thanks a lot again.
In my opinion NAV function based on CalculateMD5 from Navision Attain Hash automation will be sufficient just for distinguishing received and processed files.
However calling external MD5 utility (like one mentioned by Luc) will be (probably) faster (in terms of processing file and developing the solution), and easier to develop. Downside is that you will need copy utility to each workstation from where you're going to use your solution, and protect it from accidental deletion, or, what worse, replacement by some malicious software, etc.
Regards.
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
See this How To: How To install an OCX/DLL on the client's PC when needed (at run-time)?