![]() | ![]() | ![]() | ![]() | ![]() |
UpdateCrc32() |
This is a rexx function provided by PPWIZARD. This routine (like all PPWIZARD extensions) can be used with any operating system supported by PPWIZARD.
This function along with 2 other "helper" functions can be used to create a CRC-32 checksum for one or more blocks of memory. The routine being pure rexx is not real fast (about 40,000 bytes/sec on an Athlon 700) but would be fine for smallish blocks of memory.
In case you don't know what a CRC is it can be used for two main reasons, firstly to create a random hash of a string and secondly it can be stored for comparison with another string's CRC at some future time. Two different strings are extremely unlikely to have the same CRC value. A CRC allows you to store the CRC and not the (possibly hugh) original string.
The parameters are as follows:
The return code from each call to this routine is the updated return code.
The "Crc32InDisplayableForm()" routine when passed the binary form of the CRC will return a displayable (hexadecimal) form.
Example |
Assuming you have two variables "part1" and "part2" which contain the string for which you wish to calculate a CRC then the following code will calculate and then display one that would match that calculated by the zip utilities for the same content:
;--- Calculate the CRC ------------------------ Crc32 = Crc32PrePostConditioning(); ;;Initialize CRC value Crc32 = UpdateCrc32(Crc32, Part1); ;;Update CRC for this block Crc32 = UpdateCrc32(Crc32, Part2); ;;As above Crc32 = Crc32PrePostConditioning(Crc32); ;;Adjust CRC ;--- Display the CRC -------------------------- say 'CRC32 = ' || Crc32InDisplayableForm(Crc32); ;;Convert CRC to 8 byte displayable form
![]() | ![]() | ![]() | ![]() | ![]() |