HASH_FILE

LANSA Composer

HASH_FILE

This activity generates a hash value of the contents of the specified file according to a known algorithm.

The hash value is a fixed-length (according to the chosen algorithm), non-reversible representation of the contents of the file.  Such hash values have many uses in information security, including as a means of detecting (accidental or intentional) changes to or corruption of the source data.

For example, you could generate and store a hash value for file A.  Then, in another place or time, you could generate a hash value (using the same algorithm) for a file that purports to be file A, and by comparing the hash values you can establish that the files are the same (with a very high degree of certainty, depending on the algorithm chosen), or not (with absolute certainty).

The HASH_FILE activity returns the generated hash value in string form, either as a hexadecimal representation, or in base64-encoded form.

Note that it is NOT possible to derive the original file contents from the hash value – that is, it is non-reversible.  You should not seek to use this activity as a means of implementing reversible data encryption.

INPUT Parameters:

FILEPATH : Required

This parameter should contain the full name and path of the file for which the hash value is to be generated.

ALGORITHM : Optional

This parameter can specify the hashing algorithm to be used to generate the hash value.  If it is not specified, a default of SHA is assumed.  You can choose from the following supported algorithms:

MD2

The MD2 Message-Digest Algorithm is optimized for 8-bit computers and is no longer considered secure.

It generates a 128-bit digest (hash) value, 22 characters when *BASE64 encoded, or 32 characters when *HEX encoded.

MD5

The MD5 Message-Digest Algorithm has been employed in a wide variety of security applications, and is also commonly used to check data integrity.

It generates a 128-bit digest (hash value), 22 characters when *BASE64 encoded, or 32 characters when *HEX encoded.

SHA

SHA stands for "secure hash algorithm", and the SHA parameter value here implements the SHA-1 algorithm from the SHA family of algorithms.

It generates a 160-bit digest (hash value), 27 characters when *BASE64 encoded, or 40 characters when *HEX encoded.

SHA256
SHA384
SHA512

SHA256, SHA384 and SHA512 are a set of algorithms from the SHA-2 family.

They generate 256, 384 or 512-bit (respectively) digests (hash values), 43, 64 or 86 characters when *BASE64 encoded, or 64, 96 or 128 characters when *HEX encoded.

 

ENCODING : Optional

This parameter specifies the form of encoding applied to the generated digest or hash value (which is binary data) to produce the string representation given in the HASH output parameter.  If not specified, a default of *BASE64 is assumed.  You can choose from the following options:

*BASE64

The result is a base64-encoded representation of the generated hash value.

*HEX

The result is a hexadecimal string representation of the generated hash value.

 

OUTPUT Parameters:

HASH:

Upon successful completion, this parameter will contain the string representation of the generated hash value of the contents of the specified file, encoded according to the value of the ENCODING parameter.