OpenSSL: Hashing and HMAC’ing
Entering OpenSSL Hashing
2 min readApr 21, 2020
Hashing Messages
Under [hash_utility.sh]:
hash_message <message> e.g. output: dcd6a4f94134ae28119f32dbb048aacaafa2a0f4b52457b439501a9f102b6031
Hashing Files
Under [hash_utility.sh], this zip the folder, timestamp the file and compute the hash in 1 move:
pack_n_sha "<file_name_to_be_given>" # This command is executed within the folder which it wishes to pack
Example:
$ pack_n_sha data_for_X
data_for_X adding: .... (deflated 91%) SHA256(data_for_X_2020–04–20_2022hr_23sec.zip)= 5bc292e2e3f1d5ab166866125dca5c1efbde20405a829ba56a15d22e36689d13
To verify the hash of the file:
get_file_sha "<file_target_name>"
Example:
$ get_file_sha data_for_X_2020–04–20_2022hr_23sec.zip SHA256(data_for_X_2020–04–20_2022hr_23sec.zip)= 5bc292e2e3f1d5ab166866125dca5c1efbde20405a829ba56a15d22e36689d13$ display_hashes_of_all_files_under_folder
SHA256(./..)= 08a2343202760e9d656f69be45cea37204dd37543f73fcab2b18c9d3d6cc1be7
:
HMAC’ing Messages
For HMAC, the key must be generated 1st with [keys.sh]:
generate_key_for_hmac_sha256