Is it possible to calculate a hash value for a file on the AS/400?

Is it possible to calculate a hash value for a file on the AS/400?
SCDFITAsked:
Who is Participating?
 
tliottaCommented:
Yes, but again, what kind of "file"? The system already timestamps the last time any update happens to a data member, so you can know if any updates happened by logging that timestamp. It tracks the numbers of opens and close, writes, updates, deletes, logical and physical reads, and just about everything you could want for every physical database file in it. You can't turn it off.

However, if you really need a "hash" for some reason, try the OpenSSL product in the PASE environment. Run CALL QP2TERM to open an interactive PASE session, then:

==>   openssl sha1 </qsys.lib/myLib.lib/myFile.file/myMember.mbr

Open in new window


For a test, try a file member with a fairly limited number of records. If the physical data size is too large, various techniques handle blocks at a time.

If more details can be given about the "files", better answers are possible. For this, both the OpenSSL product and the PASE system option must be installed. (Free for both.)

Tom
0
 
Dave FordSoftware Developer / Database AdministratorCommented:
Did you want to calculate the hash-value yourself, or are you looking for some kind of "system-command" that'll do it?
0
 
SCDFITAuthor Commented:
preferably a system command.  However I am not aware of one.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Dave FordSoftware Developer / Database AdministratorCommented:
I'm not aware of any system command to generate one, but there are an infinite number of possibilities that I can come up with (just off the top of my head) to manually calculate one, and I'm sure you can do the same. The algorithm  you choose depends largely on your need to balance its complexity with its "ease of use".

On one end of the spectrum are the algorithms that are "super-simple but not as secure", and at the other end of the spectrum are ones that are "extremely complex, very secure, and very difficult to use". IMHO, the first category usually suffices.

Let us know if you need us to come up with one for you.

HTH,
DaveSlash
0
 
tliottaCommented:
Also, what is "file" and how is the hash intended to be used? Streamfiles could have different hashing possibilities from database files. And SQL tables might have differences from some native physical files. For usage, is the intent to verify file transfers? Or is it just to determine if a change has happened during some time period?

Hashing might not make much sense, depending on intended use. Other system features could make better choices.
0
 
SCDFITAuthor Commented:
We would use the hash value to determine if a file is in its original state of if at sometime a change had occurred.
0
 
Dave FordSoftware Developer / Database AdministratorCommented:
If all you need to know is whether or not a file is has changed, you could pretty easily (and programmatically) gather and compare information such as file-size, last-changed-date, number of records (at least for a native database table), file-level-identifier or member-level-identifier, and record-format.

Of course, that assumes that you're referring to a "native" file ... one that lives in the QSYS.LIB file-system. If you're referring to a file in the Integrated File System, there's whole different set of attributes you can inspect.

HTH,
DaveSlash
0
 
tliottaCommented:
And of course, journalling the file would show any actual changes. Assuming a fairly static file, receiver sizes should not ever be a problem.

Tom
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.