PL/I implementation of some hash functions.
-
CRC-32 is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to digital data.
-
SipHash is used in hash table implementations of various software (such as Python)
It is a non-collision-resistant keyed cryptographic hash function. -
SHA-2 (unkeyed cryptographic hash function) family hash functions: SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256.
I performed a parallel test of these hash algorithms on IBM Mainframe and PC. I calculated the CRC-32 and SHA-2 codes of files with FreeCommander and Total Commander (SipHash was checked online) on PC. After uploading the files to Mainframe, I repeated the hash calculation there as well. The algorithm implemented in PL/I gives the same result.
If you have a license for the C compiler on the Mainframe, you have an easier task. :)
PL/I is one of the oldest programming languages still used in present-day on IBM Mainframe computers.
CPU: IBM z15 8561-710 (big-endian)
Operating system: z/OS 2.5
Compiler: IBM(R) Enterprise PL/I for z/OS V5.R3.M0
Tested 100 times with 1 MB data.
Algorithm | Speed (MB/sec) |
---|---|
CRC-32 | 112,48 |
SipHash-2-4 64 bit | 230,41 |
SHA-224 | 223,21 |
SHA-256 | 223,71 |
SHA-384 | 64,30 |
SHA-512 | 64,47 |
SHA-512/224 | 64,35 |
SHA-512/256 | 64,64 |
More sample calls can be found in the HASH.PLI main program.
DECLARE
(ADDR,STG,NULL, UTF8,UTF8TOCHAR,HEX) BUILTIN;
%INCLUDE O(PPMMAC); /* GENERAL PL/I PREPROCESSORS MACROS */
%INCLUDE O(SHA2); /* TYPE DEFINITIONS FOR THE SHA2 ALGORITHM */
DECLARE
TEST_STR1 CHAR(43) STATIC
INIT(UTF8('The quick brown fox jumps over the lazy dog')),
SHA512_DIGEST TYPE SHA512_DIGEST_TYPE;
SHA512_DIGEST = SHA512(ADDR(TEST_STR1), STG(TEST_STR1));
PUT EDIT('TEST SHA512',
'INPUT : "', UTF8TOCHAR(TEST_STR1), '"',
'HASH VALUE : ' , HEX(SHA512_DIGEST))
(SKIP, A,
SKIP, A,A,A,
SKIP, A,A);
%INCLUDE U(SHA2); /* PL/I IMPLEMENTATION OF THE SHA2 ALGORITHM */
It gives the same result that was written in Wikipedia.
TEST SHA512
INPUT : "The quick brown fox jumps over the lazy dog"
HASH VALUE : 07E547D9586F6A73F73FBAC0435ED76951218FB7D0C8D788A309D785436BBB642E93A252A954F23912547D1E8A3B5ED6E1BFD7097821233FA0538F3DB854FEE6
Program name | Description |
---|---|
CRC32.IPU | PL/I implementation of the CRC-32 algorithm |
HASH.PLI | Main program for calling the HASH functions |
PPMMAC.IPO | General purpose PL/I preprocessors macros |
SIPHASH.IPU | PL/I implementation of the SipHash algorithm |
SHA2.IPO | Type definitions for the SHA2 functions |
SHA2.IPU | PL/I implementation of the SHA2 functions |
SYSPRINT.txt | Sample output |