XUMF5BYT ;ISS/DAVID Empey- XUMF5 MD5 Hash Utility ;06/17/05
;;8.0;KERNEL;**383**;July 10, 1995
;
;Reverses bytes in each hash string 'word' from the MD5 routine
;This is required because the MD5 routine
;presents a hashcode with each word byte-reversed
;
MAIN(HASHIN) ;
N WORD1,WORD2,WORD3,WORD4,HASHOUT
;
S WORD1=$E(HASHIN,1,8)
S WORD2=$E(HASHIN,9,16)
S WORD3=$E(HASHIN,17,24)
S WORD4=$E(HASHIN,25,32)
;
S HASHOUT=$$BYTSWTCH(WORD1)_$$BYTSWTCH(WORD2)_$$BYTSWTCH(WORD3)_$$BYTSWTCH(WORD4)
;
Q HASHOUT
;
BYTSWTCH(WORD) ;
N PIECE1,PIECE2,PIECE3,PIECE4,RESULT
;
S PIECE1=$E(WORD,1,2)
S PIECE2=$E(WORD,3,4)
S PIECE3=$E(WORD,5,6)
S PIECE4=$E(WORD,7,8)
;
S RESULT=PIECE4_PIECE3_PIECE2_PIECE1
;
Q RESULT
;
TEST ;
N OK
S OK=1
S:$$MAIN("d98c1dd404b2008f980980e97e42f8ec")'="d41d8cd98f00b204e9800998ecf8427e" OK=0
S:$$MAIN("b975c10ca8b6f1c0e299c33161267769")'="0cc175b9c0f1b6a831c399e269772661" OK=0
S:$$MAIN("98500190b04fd23c7d3f96d6727fe128")'="900150983cd24fb0d6963f7d28e17f72" OK=0
S:$$MAIN("7d696bf98d93b77c312f5a52d061f1aa")'="f96b697d7cb7938d525a2f31aaf161d0" OK=0
S:$$MAIN("d7d3fcc300e492616c49fb7d3be167ca")'="c3fcd3d76192e4007dfb496cca67e13b" OK=0
S:$$MAIN("98ab74d1f5d977d22c1c61a59f9d419f")'="d174ab98d277d9f5a5611c2c9f419d9f" OK=0
S:$$MAIN("a2f4ed5755c9e32b2eda49ac7ab60721")'="57edf4a22be3c955ac49da2e2107b67a" OK=0
I OK=1 W !,"Tests passed." Q
W !,"Tests failed."
K HASHOUT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXUMF5BYT 1476 printed Nov 22, 2024@17:20:40 Page 2
XUMF5BYT ;ISS/DAVID Empey- XUMF5 MD5 Hash Utility ;06/17/05
+1 ;;8.0;KERNEL;**383**;July 10, 1995
+2 ;
+3 ;Reverses bytes in each hash string 'word' from the MD5 routine
+4 ;This is required because the MD5 routine
+5 ;presents a hashcode with each word byte-reversed
+6 ;
MAIN(HASHIN) ;
+1 NEW WORD1,WORD2,WORD3,WORD4,HASHOUT
+2 ;
+3 SET WORD1=$EXTRACT(HASHIN,1,8)
+4 SET WORD2=$EXTRACT(HASHIN,9,16)
+5 SET WORD3=$EXTRACT(HASHIN,17,24)
+6 SET WORD4=$EXTRACT(HASHIN,25,32)
+7 ;
+8 SET HASHOUT=$$BYTSWTCH(WORD1)_$$BYTSWTCH(WORD2)_$$BYTSWTCH(WORD3)_$$BYTSWTCH(WORD4)
+9 ;
+10 QUIT HASHOUT
+11 ;
BYTSWTCH(WORD) ;
+1 NEW PIECE1,PIECE2,PIECE3,PIECE4,RESULT
+2 ;
+3 SET PIECE1=$EXTRACT(WORD,1,2)
+4 SET PIECE2=$EXTRACT(WORD,3,4)
+5 SET PIECE3=$EXTRACT(WORD,5,6)
+6 SET PIECE4=$EXTRACT(WORD,7,8)
+7 ;
+8 SET RESULT=PIECE4_PIECE3_PIECE2_PIECE1
+9 ;
+10 QUIT RESULT
+11 ;
TEST ;
+1 NEW OK
+2 SET OK=1
+3 if $$MAIN("d98c1dd404b2008f980980e97e42f8ec")'="d41d8cd98f00b204e9800998ecf8427e"
SET OK=0
+4 if $$MAIN("b975c10ca8b6f1c0e299c33161267769")'="0cc175b9c0f1b6a831c399e269772661"
SET OK=0
+5 if $$MAIN("98500190b04fd23c7d3f96d6727fe128")'="900150983cd24fb0d6963f7d28e17f72"
SET OK=0
+6 if $$MAIN("7d696bf98d93b77c312f5a52d061f1aa")'="f96b697d7cb7938d525a2f31aaf161d0"
SET OK=0
+7 if $$MAIN("d7d3fcc300e492616c49fb7d3be167ca")'="c3fcd3d76192e4007dfb496cca67e13b"
SET OK=0
+8 if $$MAIN("98ab74d1f5d977d22c1c61a59f9d419f")'="d174ab98d277d9f5a5611c2c9f419d9f"
SET OK=0
+9 if $$MAIN("a2f4ed5755c9e32b2eda49ac7ab60721")'="57edf4a22be3c955ac49da2e2107b67a"
SET OK=0
+10 IF OK=1
WRITE !,"Tests passed."
QUIT
+11 WRITE !,"Tests failed."
+12 KILL HASHOUT
+13 QUIT