CRC() Function - Cyclic Redundancy Code

Syntax

CRC(stringA{,stringB}{,ERR=lineref})

Description

The CRC() function returns a 2-byte string containing a special checksum of stringA. If stringB is given, it must be 2 bytes long and provide a "seed" for the checksum. Otherwise, PRO/5 uses a seed of $0000$. CRC() can be used for verifying data transmissions over communication lines.

Taking the CRC() of a long string that may not fit in memory can be done one piece at a time because CRC(A$+B$) = CRC(B$,CRC(A$)).

CRC algorithm:

given CRC(A$,B$)
let SEED$=B$ (or $0000$ if B$ not given)
for each byte in A$:
   "exclusive or" byte from A$ to low byte of SEED$
   do 8 times:
      shift SEED$ one bit to the right
      if a 1 bit was shifted out then
         exclusive OR $A001$ to SEED$
return(SEED$)

Examples

>LET A$=CRC("NOW IS THE TIME...")
1000 CRC$=CRC(TEXT$,SEED$,ERR=9500)

See Also

Functions - Alphabetical Listing