Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate hash file?

Former Member
0 Kudos

Hello,

There is a free program sha1sum.exe for hash file creation.

You can download it for free for testing purposes.

Anybody knows how to create a hashsum file in SAP? The input should be a data file with the content as an output the hashsum. The purpose of this hash file is to ensure the data file integrity. Any change in any character in the data file will not match then with the hash file.

I have find some hash functions in SAP but it seems they are for key purposes, not for hash file creation.

Thanks!

Rafa.

7 REPLIES 7

sandeep_katoch
Contributor
0 Kudos

Hi Rafael,

I am not sure how much these links will help but you can take a look

http://stackoverflow.com/questions/11351617/md5-hash-of-a-file-in-abap

http://scn.sap.com/thread/1483479

https://gist.github.com/3145457

May be you have already seen them but just posting in case you have not seen.

Regards,

Sandeep

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

I did not try it my self but have a look

at Function CALCULATE_HASH_FOR_RAW.

0 Kudos

Thanks Sandeep and Eitan,

I'm having a  look... I also saw that functions and:

MD5_CALCULATE_HASH_FOR_RAW

MD5_CALCULATE_HASH_FOR_CHAR

but the result is not the same as the sha1sum.exe

I'm using the CHAR one and I have read something that maybe it must be translated to binary first,..

I'm investigating

0 Kudos

Have you consider using external command:

Function module SXPG_COMMAND_EXECUTE


Use Transaction code SM69 to Maintain External OS Commands.

0 Kudos

That's a good point. I was not aware of that function module. I will review it.

On the other hand, IBM colleagues informed me about unix command "csum -h SHA1". I have double-checked this command and it returns the expected hash file.

Thanks all

0 Kudos

Hi,

Class CL_ABAP_MESSAGE_DIGEST will do the job.

Have a look at attached example program.

It depends how small/big the files are because you have to read the data into an internal table before you can hash. If the files are big, a system command might perform better but has other things to look at like authorization etc.

Kind Regards,

Jeroen.

0 Kudos

Hi,

I just did a very small test and I have the feeling that this class (CL_ABAP_MESSAGE_DIGEST) is

the winner....

Thanks for sharing Jeroen.

Rafael take notice....