Article 169043 of comp.os.vms:
In article <3368584E.504E@cri.dk>, Arne Vajhoej <ava@cri.dk> writes:
> Security Manager wrote:
>> Is anybody aware of a checksum for vms6.1?
> 
> $ CHECKSUM filename
> $ SHOW SYMB CHECKSUM$CHECKSUM

Since all this interest in CHECKSUM has come up, I thought I'd post a
little command procedure I wrote to add an internal checksum check to
a command procedure.  It's somewhat interesting.

$!----------------------------------------------------------------------------+
$!	ADD_CHECKSUM.COM - Adds internal checksum code to command procedures  |
$!----------------------------------------------------------------------------+
$!	Author: Harry Flowers
$!
$!	This command file adds code to the beginning of a command procedure
$!	given in P1 to do checksums of itself.  It loops until it succeeds;
$!	usually two or three tries does it.  The resulting command procedure
$!	is given a file type of .CHK, and can be run just like the original.
$!	Note: Running this twice on a command file will result in two checks:
$!	      the first should pass, but the second will always fail (so don't
$!	      do this).  If you have trouble, you could always add a check.
$!
$	SAVERIFY = 'F$VERIFY(0)'
$	IF F$SEARCH("CHECKSUM.HDR") .EQS. "" THEN GOSUB MAKE_HDR
$	IF P1 .EQS. "" THEN INQUIRE P1 "Command file to add checksum code to"
$	IF P1 .EQS. "" THEN GOTO FINISHED
$	FILNAM = F$SEARCH(F$PARSE(P1,"SYS$DISK:[].COM"))
$	IF FILNAM .EQS. "" THEN GOTO FINISHED
$	NEWFIL = F$PARSE(FILNAM,,,"NAME","SYNTAX_ONLY") + ".CHK"
$	WRITE SYS$OUTPUT "%CHECKSUM-I-OLDFIL, using ''FILNAM'"
$	WRITE SYS$OUTPUT "%CHECKSUM-I-NEWFIL, creating file ''NEWFIL'"
$	COPY/NOLOG CHECKSUM.HDR,'FILNAM' 'NEWFIL'
$	OLD_CHKSUM = "FEEDFACE"
$ LOOP:
$	PURGE/NOLOG/NOCONFIRM 'NEWFIL'
$	CHECKSUM 'NEWFIL'
$	CHKSUM = F$FAO("!XL",'CHECKSUM$CHECKSUM')
$	IF CHKSUM .EQS. OLD_CHKSUM THEN GOTO FINISHED
$	WRITE SYS$OUTPUT "%CHECKSUM-I-CHKSUM, trying checksum %X''CHKSUM'..."
$	CLOSE/NOLOG TMPFIL
$	OPEN/WRITE TMPFIL CHECKSUM.TMP
$	WRITE TMPFIL "SUBS /''OLD_CHKSUM'/''CHKSUM'/5/NOTYPE"
$	WRITE TMPFIL "EXIT"
$	CLOSE TMPFIL
$	DEFINE/USER SYS$OUTPUT NL:
$	DEFINE/USER SYS$ERROR  NL:
$	EDIT/EDT/COMMAND=CHECKSUM.TMP 'NEWFIL'
$	DELETE/NOLOG/NOCONFIRM CHECKSUM.TMP;*
$	OLD_CHKSUM = CHKSUM
$	GOTO LOOP
$ FINISHED:
$	WRITE SYS$OUTPUT "%CHECKSUM-I-FINISH, finished"
$	EXIT 1 + 0*F$VERIFY(SAVERIFY)		! Exit and restore verification
$!
$ MAKE_HDR:
$	WRITE SYS$OUTPUT "%CHECKSUM-I-NEWFIL, creating file CHECKSUM.HDR"
$	CREATE CHECKSUM.HDR
$	OPEN/WRITE/READ HDRFIL CHECKSUM.HDR
$	WH = "WRITE HDRFIL"
$	WH "$!----- Beginning of Checksum Code -----------------------------"
$	WH "$	MYSELF = F$ENVIRONMENT(""PROCEDURE"")"
$	WH "$	CHECKSUM 'MYSELF'"
$	WH "$	CHKSUM = 'CHECKSUM$CHECKSUM'"
$	WH "$	IF CHKSUM.EQ.%XFEEDFACE THEN GOTO CHK_PASSED ! FEEDFACE"
$	WH "$	WRITE SYS$OUTPUT ""Error: Checksum failed!"""
$	WH "$	WRITE SYS$OUTPUT F$FAO(""Checksum: %X!XL"",CHKSUM)"
$	WH "$	EXIT %X10000004"
$	WH "$ CHK_PASSED:"
$	WH "$	WRITE SYS$OUTPUT ""[Checksum matched]"""
$	WH "$!----- End of Checksum Code -----------------------------------"
$	CLOSE HDRFIL
$	RETURN

-- 
Harry Flowers
mailto:flowers@memphis.edu     http://www.people.memphis.edu/~flowers/
The University of Memphis, 112 Administration Bldg., Memphis, TN 38152


