ࡱ> = . !"#$%&'()*+,-/0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Root Entry FmZ%0PC&&0-Workbook"_VBA_PROJECT_CUR" s&0PC&&0VBA s&0I&0  !"#$%'()*+,-./023456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnoqrstuvwxyz{}~0jT0RpT00Te0T݈0T|?90|)@ZT0e0pjT0L0pjT0LZT0¼ȼ0 $0TΔdȼΔn0hO ˔̼ 0˔s0Δd̼ 0  %Y"  dMbP?_*+%MAdobe PDFS odLetterPRIV0''''0\KhCDk0EBDAStandard \p John Taylor Ba= ThisWorkbook=xiLJ$8X@"1Arial1Arial1Arial1Arial1Arial1Courier"$"#,##0_);\("$"#,##0\)!"$"#,##0_);[Red]\("$"#,##0\)""$"#,##0.00_);\("$"#,##0.00\)'""$"#,##0.00_);[Red]\("$"#,##0.00\)7*2_("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_).))_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)?,:_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)6+1_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)                + ) , *    8U@@ 8UU@ @ 8PU @ 8@@ 8U@ @ 8P @ 8@@ 8U@ @ 8P @ 8Q@@ 8UQ@ @ 8PQ @ 8U@@ 8@ 8U@ 8P  8@@  8Q@@ `Sheet1sha1sha1hex abc Empty textDigestNotes+The quick brown fox jumps over the lazy dog+The quick brown fox jumps over the lazy cog6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.a...a (54 characters=1 block-1 after padding)7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,a...a (55 characters=1 block after padding)8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.a...a (56 characters=1 block+1 after padding)8abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcde...mnopnopq61 62 63Hex version of 'abc'A000000000BFFF Hex stringA000000000bfffA0 00 00 00 00 B FFFA000000000C000 Empty TextNormal character stringASCII Hex stringMessage01234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345671Just really long (Relative to the other examples) 6 1 6 2 6 3 61 6 26 3 <ɦ >h _Titlerea<<>̻H J tem32\Msimtf.dll(Н0azp0J J 0J S0dt00@ Sheet1 ThisWorkbook Sheet1 Module1]__SRP_2p<МGzFI2dNlyKx8ĩp#I2dNlyKМGz4(SLSS6"N0{00020819-0000-0000-C000-000000000046}9E $*\Rffff*6745903df8($H`$ $ $ $0h@hh0MExAttribute VB_Name = "ThisWorkbook" Bas0{00020P819-0C$0046} |CreatablFalse ^PredeclaIdTru "@ExposeTemplateD0eriv$eCustomiz2<D3sN7S2 F8,@d~$5x8ĩ#8,@d~$5D3sN7S24(SLSS6"N0{00020820-0000-0000-C000-000000000046}9E $*\Rffff*6845903df8(o|$H` $ $ $0h@0MExAttribute VB_Name = "She@et1" Bast0{00020820- C$0046} |CreatablFalse PredeclaIdTru "ExposeTemplate`Deriv$eCustomizdrU ,`ay00,`0 MEcB  rj (k @k Hk `k xk k k k rk `8l &l \l  m (m 0m Pm hm m m m m m m m "n .0n (`n (n .n n n Xn pHo Po rp6p Rp,q R@q8q6q4r>@r(r Rr,s@0s,psssss8s"s R t2xt t Rt"(uPu rpu u v $v8vHvXvhvxv v v &vvx "ĩ<"4? (> <9E $*\Rffff*19459d39bb*\R0*#d*\R0*#c+ `k@i  `Y0i" $``&@\`(X`*V`,P .8HA0`06`24 4Q`6``8`:h d`< 5 x >`ing H`@P`B8niti`Dh In`F0 `H1 +X `hf+ <<476i\ @i^``t `bp'0 `d`n <=`f l"1 `hh0 <=`jf 0x8 V`(L+0 44ilPin`pj`rh`Hf`t0`+v` ,,Kil0in`x`H`t+N``l+..wil in`rv`Ht`tp R`P+ ((ilin`Hj`td+Z`0kP il piz`Hv`|Pp+L0 `ZkFFil `Ft`r`hl`Hj`8d`h``^ il `Ft( $+ ` |k %%3``Hr`|l $$ $+ ` pkH  Xi  h il +` i\ i^0 `  $H H h H p ` `x H X  @@ t @p p X  H X p `x X 3@ j  <@@h ` <@LP@@X @pH @08 @( @ 0H=@ @ @ @ @ @ @ @ X A@h @H@/ hH@ @ @| hJP HpX0x`Lx @\ @Z JL~T@0H @8 ctio@`( @H @p `x @ @ @ @ @ @0 @ @ @x p@t @p @l @j  @h H@d 0@\ @Z  0`8hP(`8P` xx8@ `J@ @J^JLNPRT@ @P @ @ @ (K@hx @h @X @H @8 @( @ @  ////O@ P@ @ @ @ w@/ w@ |@0 |8H~ @X pp0 @ XX@ @ VXZp @0 H@X p0`@H (X@ @ @ @ @ @ @ 80`@p H@ p@ p0`H`x`Nx`w@n Then@l  @Rl @T @R data@P Pp@Vl  to  'if @P at t@0N hex(H* @L X0*0> assx@ `Xx 8),p0`Zxt AsF~J$L$@H` %in@`P or t@@ Eg@x0 >@ 2@ >0  x %w,Lw5Hwhw pw$Fw"<w"<w"<w"< xHx  ,Pxxxxxx px *@y fpyy Vy(Hz ,`z("z9z Bz H {(h{({({({$C{$C{$C|,@| p`| *|" } n(}6>} .}~(?~ @~ FP~~&$~80~80.#H x 0ZT 0 L@Ѐ  bv( Ts l} xTs  60hȃ p x p 0(@&,X  n  B  \ Lx PȆ R ,p  ȇ "Ї  Zx 0` \ \ "" " 8 "H p LЊ   NH @X  Ћ   B  \ؤ R P8 R ,   8 "@ h Z0 0p \  B  P DP $  NȌ Phpx P؍    0@PX`h pЎ؎   ( B  0 P8 D $Џ  N PP P 08@ H ` pF    B ( P0 B Ȓ  L P@ P    ( 8@H P hȔД   B  P D`  ȕ NЕ P px PЖ  ؖ     (F@   B  ` B XX ^ , `@ `  ( 0L0 ` h B p Xx FК * XHțЛ X؛ &0X%p,L5؜ &! 0@P *` 0 (Н .cHPX ` p  "0ȞО"!*%H P `  p  B  X N XhȠР Xؠ &0X%p,L5ء 0  0@ H(Uh   B  P H FP N P"X p l//////////////////////////////////////////////////////////////////////////////////////////////////////////// dependencies i32shiftleft i32shiftright i32rotatelefti32addhextodecdectohexl////////////////////////////////////////////////////////////////////////////////////////////////////////////Ykeydata is 4 x int32 ascii hex string, if null the default key will be used (msb at left)message is raw binary, unpaddedUreturn data is 5 x int32 ascii hex string with space between each int32 (msb at left)Hash initialization data Index Data0 0x674523011 0xEFCDAB892 0x98BADCFE3 0x103254764 0xC3D2E1F0 Default keyIndex Key Rounds'0 0x5A827999 0 <= i <= 19 LSB"1 0x6ED9EBA1 20 <= i <= 39"2 0x8F1BBCDC 40 <= i <= 59'3 0xCA62C1D6 60 <= i <= 79 MSBQthese calls would be the equivalent of using the default key as shown in the specjuserhash = sha1("CA62C1D68F1BBCDC6ED9EBA15A827999","abc") = "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D"Juserhash = sha1("","abc") = "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D"k///////////////////////////////////////////////////////////////////////////////////////////////////////////Z"key constants defined in SHA1 specL----------------------------------------------------------------------------Zexternal block(m) loop counterL----------------------------------------------------------------------------Z*size in bits of original message (Pre-pad)Z'used to determine how many zeros to padZ%64 byte chunk of message, as a stringZ@)block buffer, translated to w(0) to w(15)Zblock parser loop counterL----------------------------------------------------------------------------Zinternal word(t) loop counterZP+word sequence, w(16) to w(79) are prehashedZWord buffers for working blockZZZZZ#updated from a...e after each blockZtemporary word valueL----------------------------------------------------------------------------Z#output builder for ascii hex resultZbuild loop counterL----------------------------------------------------------------------------Zcleaned up key dataZcleanup counterk/////////////////////////////////////////////////////////////////////////////////////////////////////////// mode control use default key from SHA1 specyZ+$n+$ܼ+$bʤ+$a(use key passed to functionfront pad with zeros strip out all non hex characters H   H$09IafIAFIQ F  H$ 'Fk8 H 0$^ F $J'F F$$L+$ F$$L+$ F $$L+$ F$$L+$hX%initialize hash data for this message#Eg+>+>ܺ+>vT2+>ä+>i/////////////////////////////////////////////////////////////////////////////////////////////////////////$pad message to 1 to n 512 bit blocks`save length of original message in bits (Bytes * 8), but use shift function to avoid vb overflow "$N'(Pappend a '1' bit to the end of the message (this is actually a '1' with 7 '0's!) "$P '"&pad with zeros to make mod(64)-8 bytes@ " @  ?'* " *$P$^ '";the last 8 bytes is the count of message bits, or bytes x 8Bthis is only (32bits/8bitsperbyte)= 536,870,911 bytes cause I suck "$P '" "$P '" "$P '" "$P '" " ($R$P '" " ($R$P '" " ($R$P '" " ($P '"i/////////////////////////////////////////////////////////////////////////////////////////////////////////$do hash in 64 byte blocks (512 bits) & "@h//////////////////////////////////////////////////////////////////////////////////////////////////////// " "@ & @ @$','parse out 64 bytes into 16 32 bit words 0? , 0 $$T 0+. 0?convert byte data in message block to 32int in first 16 w words 2 2$.U $N 2+4 2$4 2 $.U $N 2+4 2$4 2 $.U $N 2+4 2$4 2 $.U  2+4 2*pre-hash w(0) to w(15) into w(16) to w(79) 2O 2 $4 2 $4 2 $4 2 $4$V 2+4 2Finitialize counters for this block from running hash for whole message$>'6$>'$>'8$>':$>'<do the actual hash 2O 2IQ 6$V <$X 2$4$X$$$X  8  :$X'@'IQ 6$V <$X 2$4$X$$$X  8 :$X'@(;IQ 6$V <$X 2$4$X$$$X  8  : 8 :$X'@<OIQ 6$V <$X 2$4$X$$$X  8 :$X'@k :'< 8': $V'8 6' @'6 2/update running hash with results for this block$> 6$X+>$> $X+>$> 8$X+>$> :$X+>$> <$X+>i///////////////////////////////////////////////////////////////////////////////////////////////////////// &i/////////////////////////////////////////////////////////////////////////////////////////////////////////*return result of hash as 5 ascii hex words$>$Z'B D B D$>$Z 'B D B' h////////////////////////////////////////////////////////////////////////////////////////////////////////fFdoes 32 bit add of two 32 bit numbers as if they were unsigned int32'sIthis has to be done this way because of quirk in VB where an add overflowLinto the sign bit is kicked out as an error. This would not be a problem if%an unsigned int32 were allowed in VB!result=operanda + operandbuse this function for (a+b)X(-), Not, And, Or, Xor all work the same for signed and unsigned int32 because there are)no carries or borrows for VB to deal withV//////////////////////////////////////////////////////////////////////////////////////ZZZZZZV//////////////////////////////////////////////////////////////////////////////////////trim off offending bits \?'` ^?'b \@'d ^@'fdo math on lower order bits ` b 'hdo math on upper order bits d f 'jEif there was an overflow into upper 2 bits, increment the accumulator h@ j 'jhGget rid of an overflow into upper 2 bits in lieu of separate math below h?'h:now adjust the upper bits for the side calculation results j h@'hhH j h'hh  h'Xf=does a left rotate on a signed integer as if it were unsigned (MSB) < MSB.....LSB < (MSB)Gfor i=0 to 32:print dectohex(i32rotateleft(&h0000000f,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZZZJ////////////////////////////////////////////////////////////////////////// l't n  n l'VsHh@ H nget msb t'pa'ph get msb-1 bit t@'ra'rh t?'t p t'thh r t'thH H t'Vf(>does a right rotate on a signed integer as if it were unsigned (LSB) > MSB.....LSB > (LSB)Hfor i=0 to 32:print dectohex(i32rotateright(&hf0000000,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZZJ////////////////////////////////////////////////////////////////////////// l't n  n l'vshh` H nget lsb t'xa'xh t't-'without the "INT()", its really broken! x t'th H t'vf<does a left shift on a signed integer as if it were unsigned MSB.....LSB < (0)Ffor i=0 to 32:print dectohex(i32shiftleft(&hffffffff,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZZJ////////////////////////////////////////////////////////////////////////// l't n l'Nsh n 'Nsh H n get msb-1 bit t@'raX'rhH t?'t r t'th H t'Nf`=does a right shift on a signed integer as if it were unsigned (0) > MSB.....LSBGfor i=0 to 32:print dectohex(i32shiftright(&hffffffff,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZJ////////////////////////////////////////////////////////////////////////// l't n l'RsPhH n 'Rs(h  H n t't-'without the "INT()", its really broken! H t'RfZZY/////////////////////////////////////////////////////////////////////////////////////////<converts 32 bit signed integer to hex string of n hex digitsRsince datain is specified here as long, -1 gets converted with hex() to "FFFFFFFF"Wif you just type it in at the immediate window hex() would convert -1 to "FFFF" because&only a 16bit integer would be assumed!Y///////////////////////////////////////////////////////////////////////////////////////// z 'zhx00000000 l$~ $J z$J'| |'Zf8ZZZZZZZQ/////////////////////////////////////////////////////////////////////////////////9converts 8 character hexadecimal to 32 bit signed integerQ///////////////////////////////////////////////////////////////////////////////// strip out all non hex characters H l l H$09IafIAFIQ F l H$ 'FkX Htrim off more than 8 characters F$J'F F F$07IQ$do nothing since VB can handle this!'P)post process result to get sign in there!"trim to 31 bits, do sign bit lateronly slightly recursive! F$$L $~ F'kh F$'F F''h H  F  H  $' 09IQ H  $'AFIQ H  $T7 'k h  'h H  h'La h  'Lh f l//////////////////////////////////////////////////////////////////////////////////////////////////////////// dependencies i32shiftleft i32shiftright i32rotatelefti32addhextodecdectohexl////////////////////////////////////////////////////////////////////////////////////////////////////////////Ykeydata is 4 x int32 ascii hex string, if null the default key will be used (msb at left)message is raw binary, unpaddedUreturn data is 5 x int32 ascii hex string with space between each int32 (msb at left)Hash initialization data Index Data0 0x674523011 0xEFCDAB892 0x98BADCFE3 0x103254764 0xC3D2E1F0 Default keyIndex Key Rounds'0 0x5A827999 0 <= i <= 19 LSB"1 0x6ED9EBA1 20 <= i <= 39"2 0x8F1BBCDC 40 <= i <= 59'3 0xCA62C1D6 60 <= i <= 79 MSBQthese calls would be the equivalent of using the default key as shown in the specjuserhash = sha1("CA62C1D68F1BBCDC6ED9EBA15A827999","abc") = "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D"Juserhash = sha1("","abc") = "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D"k///////////////////////////////////////////////////////////////////////////////////////////////////////////Z"key constants defined in SHA1 specL----------------------------------------------------------------------------Zexternal block(m) loop counterL----------------------------------------------------------------------------Z*size in bits of original message (Pre-pad)Z'used to determine how many zeros to padZ%64 byte chunk of message, as a stringZ@)block buffer, translated to w(0) to w(15)Zblock parser loop counterL----------------------------------------------------------------------------Zinternal word(t) loop counterZP+word sequence, w(16) to w(79) are prehashedZWord buffers for working blockZZZZZ#updated from a...e after each blockZtemporary word valueL----------------------------------------------------------------------------Z#output builder for ascii hex resultZbuild loop counterL----------------------------------------------------------------------------Zcleaned up key dataZcleanup counterk/////////////////////////////////////////////////////////////////////////////////////////////////////////// mode control use default key from SHA1 specyZ+$n+$ܼ+$bʤ+$ause key passed to functionfront pad with zeros strip out all non hex characters H   H$09IafIAFIQ F  H$ 'Fk H 0$^ F $J'F F$$L+$ F$$L+$ F $$L+$ F$$L+$h?%initialize hash data for this message#Eg+>+>ܺ+>vT2+>ä+>i/////////////////////////////////////////////////////////////////////////////////////////////////////////$pad message to 1 to n 512 bit blocks`save length of original message in bits (Bytes * 8), but use shift function to avoid vb overflow "$N'(Pappend a '1' bit to the end of the message (this is actually a '1' with 7 '0's!) "$P '"&pad with zeros to make mod(64)-8 bytes@ " @  ?'* " *$P$^ '";the last 8 bytes is the count of message bits, or bytes x 8Bthis is only (32bits/8bitsperbyte)= 536,870,911 bytes cause I suck "$P '" "$P '" "$P '" "$P '" " ($R$P '" " ($R$P '" " ($R$P '" " ($P '"i/////////////////////////////////////////////////////////////////////////////////////////////////////////$do hash in 64 byte blocks (512 bits) & "@h//////////////////////////////////////////////////////////////////////////////////////////////////////// " "@ & @ @$','parse out 64 bytes into 16 32 bit words 0? , 0 $$T 0+. 0?convert byte data in message block to 32int in first 16 w words 2 2$.U $N 2+4 2$4 2 $.U $N 2+4 2$4 2 $.U $N 2+4 2$4 2 $.U  2+4 2*pre-hash w(0) to w(15) into w(16) to w(79) 2O 2 $4 2 $4 2 $4 2 $4$V 2+4 2Finitialize counters for this block from running hash for whole message$>'6$>'$>'8$>':$>'<do the actual hash 2O 2IQ 6$V <$X 2$4$X$$$X  8  :$X'@'IQ 6$V <$X 2$4$X$$$X  8 :$X'@(;IQ 6$V <$X 2$4$X$$$X  8  : 8 :$X'@<OIQ 6$V <$X 2$4$X$$$X  8 :$X'@kH5 :'< 8': $V'8 6' @'6 2/update running hash with results for this block$> 6$X+>$> $X+>$> 8$X+>$> :$X+>$> <$X+>i///////////////////////////////////////////////////////////////////////////////////////////////////////// &i/////////////////////////////////////////////////////////////////////////////////////////////////////////*return result of hash as 5 ascii hex words$>$Z'B D B D$>$Z 'B D B' h////////////////////////////////////////////////////////////////////////////////////////////////////////f 2V//////////////////////////////////////////////////////////////////////////////////////Fdoes 32 bit add of two 32 bit numbers as if they were unsigned int32'sIthis has to be done this way because of quirk in VB where an add overflowLinto the sign bit is kicked out as an error. This would not be a problem if%an unsigned int32 were allowed in VB!result=operanda + operandbuse this function for (a+b)X(-), Not, And, Or, Xor all work the same for signed and unsigned int32 because there are)no carries or borrows for VB to deal withV//////////////////////////////////////////////////////////////////////////////////////ZZZZZZV//////////////////////////////////////////////////////////////////////////////////////trim off offending bits \?'` ^?'b \@'d ^@'fdo math on lower order bits ` b 'hdo math on upper order bits d f 'jEif there was an overflow into upper 2 bits, increment the accumulator h@ j 'jh8-Gget rid of an overflow into upper 2 bits in lieu of separate math below h?'h:now adjust the upper bits for the side calculation results j h@'hhp, j h'hhH, h'Xf8,J//////////////////////////////////////////////////////////////////////////=does a left rotate on a signed integer as if it were unsigned (MSB) < MSB.....LSB < (MSB)Gfor i=0 to 32:print dectohex(i32rotateleft(&h0000000f,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZZZJ////////////////////////////////////////////////////////////////////////// l't n  n l'Vs *h* H nget msb t'pa)'ph) get msb-1 bit t@'ra)'rhx) t?'t p t'th@) r t'th ) H t'Vf)J//////////////////////////////////////////////////////////////////////////>does a right rotate on a signed integer as if it were unsigned (LSB) > MSB.....LSB > (LSB)Hfor i=0 to 32:print dectohex(i32rotateright(&hf0000000,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZZJ////////////////////////////////////////////////////////////////////////// l't n  n l'vs&h& H nget lsb t'xa&'xh& t't-'without the "INT()", its really broken! x t'th(& H t'vf&J//////////////////////////////////////////////////////////////////////////<does a left shift on a signed integer as if it were unsigned MSB.....LSB < (0)Ffor i=0 to 32:print dectohex(i32shiftleft(&hffffffff,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZZJ////////////////////////////////////////////////////////////////////////// l't n l'Ns$h$ n 'Ns#h# H n get msb-1 bit t@'ra#'rh# t?'t r t'thH# H t'Nf(#`J//////////////////////////////////////////////////////////////////////////=does a right shift on a signed integer as if it were unsigned (0) > MSB.....LSBGfor i=0 to 32:print dectohex(i32shiftright(&hffffffff,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZJ////////////////////////////////////////////////////////////////////////// l't n l'Rs8!h0! n 'Rs!h! H n t't-'without the "INT()", its really broken! H t'Rf Y/////////////////////////////////////////////////////////////////////////////////////////<converts 32 bit signed integer to hex string of n hex digitsRsince datain is specified here as long, -1 gets converted with hex() to "FFFFFFFF"Wif you just type it in at the immediate window hex() would convert -1 to "FFFF" because&only a 16bit integer would be assumed!Y/////////////////////////////////////////////////////////////////////////////////////////ZZY///////////////////////////////////////////////////////////////////////////////////////// z 'zh00000000 l$~ $J z$J'| |'ZfQ/////////////////////////////////////////////////////////////////////////////////?converts up to 8 character hexadecimal to 32 bit signed integer#non hex characters are stripped outQ/////////////////////////////////////////////////////////////////////////////////ZZZZZZZQ///////////////////////////////////////////////////////////////////////////////// strip out all non hex characters H l l H$09IafIAFIQ F l H$ 'FkP Htrim off more than 8 characters F$J'F F F$07IQ$do nothing since VB can handle this!'P)post process result to get sign in there!"trim to 31 bits, do sign bit lateronly slightly recursive! F$$L $~ F'kh F$'F F''h H  F  H  $' 09IQ H  $'AFIQ H  $T7 'k h  'h H  h'La h  'Lhfx0 Q/////////////////////////////////////////////////////////////////////////////////Gconverts ascii hex block to raw binary (1 byte per 2 characters) stringQ/////////////////////////////////////////////////////////////////////////////////ZZZQ///////////////////////////////////////////////////////////////////////////////// strip out all non hex characters H l l H$09IafIAFIQ F l H$ 'FkP H*ensure even number of ascii hex characters F 0 F 'Fh H F  | F H$$L$P '| H |'f fp  l$$ 'Pl//////////////////////////////////////////////////////////////////////////////////////////////////////////// dependencies i32shiftleft i32shiftright i32rotatelefti32addhextodecdectohexl////////////////////////////////////////////////////////////////////////////////////////////////////////////Ykeydata is 4 x int32 ascii hex string, if null the default key will be used (msb at left)message is raw binary, unpaddedUreturn data is 5 x int32 ascii hex string with space between each int32 (msb at left)Hash initialization data Index Data0 0x674523011 0xEFCDAB892 0x98BADCFE3 0x103254764 0xC3D2E1F0 Default keyIndex Key Rounds'0 0x5A827999 0 <= i <= 19 LSB"1 0x6ED9EBA1 20 <= i <= 39"2 0x8F1BBCDC 40 <= i <= 59'3 0xCA62C1D6 60 <= i <= 79 MSBQthese calls would be the equivalent of using the default key as shown in the specjuserhash = sha1("CA62C1D68F1BBCDC6ED9EBA15A827999","abc") = "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D"Juserhash = sha1("","abc") = "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D"k///////////////////////////////////////////////////////////////////////////////////////////////////////////Z"key constants defined in SHA1 specL----------------------------------------------------------------------------Zexternal block(m) loop counterL----------------------------------------------------------------------------Z*size in bits of original message (Pre-pad)Z'used to determine how many zeros to padZ%64 byte chunk of message, as a stringZ@)block buffer, translated to w(0) to w(15)ZPblock parser loop counterL----------------------------------------------------------------------------Zhinternal word(t) loop counterZP+word sequence, w(16) to w(79) are prehashedZWord buffers for working blockZZZZZ0#updated from a...e after each blockZhtemporary word valueL----------------------------------------------------------------------------Z#output builder for ascii hex resultZbuild loop counterL----------------------------------------------------------------------------Zcleaned up key dataZcleanup counterk/////////////////////////////////////////////////////////////////////////////////////////////////////////// mode control use default key from SHA1 specyZ+$n+$ܼ+$bʤ+$a^use key passed to functionfront pad with zeros strip out all non hex characters H   H$09IafIAFIQ F  H$ 'Fk] H 0$^ F $J'F F$$L+$ F$$L+$ F $$L+$ F$$L+$h]%initialize hash data for this message#Eg+>+>ܺ+>vT2+>ä+>i/////////////////////////////////////////////////////////////////////////////////////////////////////////$pad message to 1 to n 512 bit blocks`save length of original message in bits (Bytes * 8), but use shift function to avoid vb overflow "$N'(Pappend a '1' bit to the end of the message (this is actually a '1' with 7 '0's!) "$P '"&pad with zeros to make mod(64)-8 bytes@ " @  ?'* " *$P$^ '";the last 8 bytes is the count of message bits, or bytes x 8Bthis is only (32bits/8bitsperbyte)= 536,870,911 bytes cause I suck "$P '" "$P '" "$P '" "$P '" " ($R$P '" " ($R$P '" " ($R$P '" " ($P '"i/////////////////////////////////////////////////////////////////////////////////////////////////////////$do hash in 64 byte blocks (512 bits) & "@h//////////////////////////////////////////////////////////////////////////////////////////////////////// " "@ & @ @$','parse out 64 bytes into 16 32 bit words 0? , 0 $$T 0+. 0?convert byte data in message block to 32int in first 16 w words 2 2$.U $N 2+4 2$4 2 $.U $N 2+4 2$4 2 $.U $N 2+4 2$4 2 $.U  2+4 2*pre-hash w(0) to w(15) into w(16) to w(79) 2O 2 $4 2 $4 2 $4 2 $4$V 2+4 2Finitialize counters for this block from running hash for whole message$>'6$>'$>'8$>':$>'<do the actual hash 2O 2IQ 6$V <$X 2$4$X$$$X  8  :$X'@'IQ 6$V <$X 2$4$X$$$X  8 :$X'@(;IQ 6$V <$X 2$4$X$$$X  8  : 8 :$X'@<OIQ 6$V <$X 2$4$X$$$X  8 :$X'@kxR :'< 8': $V'8 6' @'6 2/update running hash with results for this block$> 6$X+>$> $X+>$> 8$X+>$> :$X+>$> <$X+>i///////////////////////////////////////////////////////////////////////////////////////////////////////// &i/////////////////////////////////////////////////////////////////////////////////////////////////////////*return result of hash as 5 ascii hex words$>$Z'B D B D$>$Z 'B D B' h////////////////////////////////////////////////////////////////////////////////////////////////////////fPOV//////////////////////////////////////////////////////////////////////////////////////Fdoes 32 bit add of two 32 bit numbers as if they were unsigned int32'sIthis has to be done this way because of quirk in VB where an add overflowLinto the sign bit is kicked out as an error. This would not be a problem if%an unsigned int32 were allowed in VB!result=operanda + operandbuse this function for (a+b) Kdoes 32 bit subtract of two 32 bit numbers as if they were unsigned int32's are)no carries or borrows for VB to deal withV//////////////////////////////////////////////////////////////////////////////////////Z`ZxZZZZV//////////////////////////////////////////////////////////////////////////////////////trim off offending bits \?'` ^?'b \@'d ^@'fdo math on lower order bits ` b 'hdo math on upper order bits d f 'jEif there was an overflow into upper 2 bits, increment the accumulator h@ j 'jhhJGget rid of an overflow into upper 2 bits in lieu of separate math below h?'h:now adjust the upper bits for the side calculation results j h@'hhI j h'hhxI h'XfhIJ//////////////////////////////////////////////////////////////////////////=does a left rotate on a signed integer as if it were unsigned (MSB) < MSB.....LSB < (MSB)Gfor i=0 to 32:print dectohex(i32rotateleft(&h0000000f,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZpZZZJ////////////////////////////////////////////////////////////////////////// l't n  n l'VsPGhHG H nget msb t'paG'phF get msb-1 bit t@'raF'rhF t?'t p t'thpF r t'thPF H t'Vf0FJ//////////////////////////////////////////////////////////////////////////>does a right rotate on a signed integer as if it were unsigned (LSB) > MSB.....LSB > (LSB)Hfor i=0 to 32:print dectohex(i32rotateright(&hf0000000,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZPZhZJ////////////////////////////////////////////////////////////////////////// l't n  n l'vs DhD H nget lsb t'xaC'xhC t't-'without the "INT()", its really broken! x t'thXC H t'vf8CJ//////////////////////////////////////////////////////////////////////////<does a left shift on a signed integer as if it were unsigned MSB.....LSB < (0)Ffor i=0 to 32:print dectohex(i32shiftleft(&hffffffff,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZ0ZHJ////////////////////////////////////////////////////////////////////////// l't n l'Ns@Ah8A n 'NsAhA H n get msb-1 bit t@'ra@'rh@ t?'t r t'thx@ H t'NfX@`J//////////////////////////////////////////////////////////////////////////=does a right shift on a signed integer as if it were unsigned (0) > MSB.....LSBGfor i=0 to 32:print dectohex(i32shiftright(&hffffffff,int(i)),8):next iJ//////////////////////////////////////////////////////////////////////////ZZJ////////////////////////////////////////////////////////////////////////// l't n l'Rsh>h`> n 'Rs@>h8> H n t't-'without the "INT()", its really broken! H t'Rf=Y/////////////////////////////////////////////////////////////////////////////////////////<converts 32 bit signed integer to hex string of n hex digitsRsince datain is specified here as long, -1 gets converted with hex() to "FFFFFFFF"Wif you just type it in at the immediate window hex() would convert -1 to "FFFF" because&only a 16bit integer would be assumed!Y/////////////////////////////////////////////////////////////////////////////////////////ZZY///////////////////////////////////////////////////////////////////////////////////////// z 'zh0;00000000 l$~ $J z$J'| |'Zf:Q/////////////////////////////////////////////////////////////////////////////////?converts up to 8 character hexadecimal to 32 bit signed integer#non hex characters are stripped outQ/////////////////////////////////////////////////////////////////////////////////Z Z8ZPZhZZZQ///////////////////////////////////////////////////////////////////////////////// strip out all non hex characters H l l H$09IafIAFIQ F l H$ 'Fk8 Htrim off more than 8 characters F$J'F F F$07IQ$do nothing since VB can handle this!'P7)post process result to get sign in there!"trim to 31 bits, do sign bit lateronly slightly recursive! F$$L $~ F'k7h7 F$'F F''h H  F  H  $' 09IQ H  $'AFIQ H  $T7 'k6 h  'h H  h'La5 h  'Lh5f50 Q/////////////////////////////////////////////////////////////////////////////////Gconverts ascii hex block to raw binary (1 byte per 2 characters) stringQ/////////////////////////////////////////////////////////////////////////////////ZZp Z Q///////////////////////////////////////////////////////////////////////////////// strip out all non hex characters H l l H$09IafIAFIQ F l H$ 'Fk3 H*ensure even number of ascii hex characters F 0 F 'Fh3 H F  | F H$$L$P '| H |'f2 J//////////////////////////////////////////////////////////////////////////Bthis is needed by excel because it does not accept null characters@in raw binary strings so this has to all be done at module levelHwithout passing interrim result back to spreadsheet (Which truncates thestring at the first null)J//////////////////////////////////////////////////////////////////////////  l$$ 'f0SNot, And, Or, Xor all work the same for signed and unsigned int32 because there areV//////////////////////////////////////////////////////////////////////////////////////Ithis has to be done this way because of quirk in VB where an add overflowLinto the sign bit is kicked out as an error. This would not be a problem if%an unsigned int32 were allowed in VB!result=operanda - operandbuse this function for (a-b))no carries or borrows for VB to deal withV////////////////////////////////////////////////////////////////////////////////////// \ ^$X$X'f--SNot, And, Or, Xor all work the same for signed and unsigned int32 because there arehXt, And, Or, Xor all work the same for signed and unsigned int32 because there areXnAttribute VB_Name = "Module1" Public Function sha1(keydata As Sng, mesPsage$)  '/hndependenciesi32shiftleftrighrotateaddhextodectolgis 4 x int32 ascHii G sif null the default  wi be used (msb at t)eraw binary,P unp@e@return B|@ 5V th space between each,MHasitializaIpx &D@0 0x674523011EFCDA(B89298@BADCFE31032547 64C3D2E1F0DNcD!Key BR0oundF%5A827999<= i 1LSB*6ED9EBA20 B 3 /8F1BBCDC4 5 F3CA62C1D6 6 7Mse calls would@gequivalent ofCingGas`~own8bspa`IrhA7=C"e"","ab(c")A$3E36 4706816A BA3E2571 7850C26C 9C@D0D89D`' w??" Dim k(4Lo+A5g'sconstantsvin`tin SHDd--?$CmcWtera'ernal block(m) loop $?I ?%si6z)'"bi[$To@`l&(Pre-- Integ-aHd to,`m@- how many zerosachunk؇6 '64 by@c,\ aj)6#ABa buffer, tran sl`bw(0)w(15Db6l'C pars6?4C tq 'i#word(t#1w(8 Ѓ''Q sIQ{e, 6t79) are preGib 'W s forrOrkQN bױ cd)arunn(b5K>'up`l b#P)ate mp``*add(C-a, 50e70Q!k(("b"uc) )((No23\d) "223?2? ?:". c PQ# 34B5OOhOJR1SdSc"6c??߃6VbE` A%d'c(0b, 3 +aA-9" 3 (up Pe1result4 2'{, a.91R!"{0\292`*cC=aT}3dDsh(4estEtU_`return C1 as 5@cii h,exot!u= decto(0eALh|1|4'+ "+(U"+5 sha1p' a8Function;Publi,c )oanda As LongPFV? _ does2qtwonumbersQ iry were unsignDed~32'P'uAbe do neway beΐquirkp VB wh1an flow@ qQpkick@)@error. Twould nje problem ifg C ow2 !p /=+ nb!ےfb(a+bB0 r,b,s,[`a3ke same" arePno carriPbowsXPdeal 1Z[/% Dim operand_ax As Long .b .up`_aXInteg,er^.b.re0sult[topbits +'&A*( 'trsff offending > }=lnd &H3Fsa= ((+%C0) /,4A!3 /mdo math on lower ord@7^F-x+|bx KB"Jj= C)(a +Dbif there was an overf" intRoC 2B[,c@rement accumulatoIf UH Then !E+ 1 d E@ If2get rid@y["A" lieu separateQbe. M$now adjus3G9 for7side chalc8igs ;1A19r=BOr;2 8M i32add  !9!)Funct@kPublic b sub\,eKW#)~{z01does 3L tract;twonumb$er@Ts CVy ee unsigned`Bt32'3'this hYXbe done:`way b@ecause quirkaIVB wb`_*e` `d C kicBk out ferror. 8 ould not` a problem  alVb VB!@cI=&-F3"f>W(a-b)Not, S, Or, XcZ wo`ameB' Ȍ)f%are no`brri6 bo ws(.deal with`A?/_D_`(E%, @%), >1 "gd)` rotleft(datainEa,Acoud.O?#B1a  1ba("{(1 it0 (M@SB) < `.LSBR 1Ni=0Y`6:pr. dectohexQ&hdHf,P(i)),8):next >i //9msH0_m1Ajix O = cV](bit3!>=)P7 7<= 0)v^%p,d%QpExW*qh F6ifo''Qs` i&Hc aEls = C0By-1_n~Q=} *s\ z) * 2q  w@`F @=zvN.BG0$/wQ5w2righEf$E.?x*`1$F?F2u?F"w0F@E) >:F> (Q+ ?Ft?Fe&hfTFOFo EFlOF D%?DQ#0+CDt DjswI`,DѶDKA6B?75w .>CS=s= P[(/ 2@&H7t8 'qQ"I`NT()"P`rPlroken 0O=O="% TO='_=U=q=2shift/>g/`C-/: 'does a left shi onsigned integer as if it were un<| MSB.LSB < (0)for i=0 to 32:prI dectohex(i32ku(&hf,$(i)),8):next iH; Dim msb_m1 As In ixdatain 0LongLE.= 3 If (bitcount <= 0) Then  Ex@eFunctio@ @End If>=@aV0AFAr1 To 'A 'getS-1A05A"&H4601  _= 1A ElseC#1 = ( 3F) * ~2@wEMIOr &H8% LND [DU [APublic  Eright(Cy,RAA%Ud{{{y >I| @{{_? x x? * JxxC2xx yiy Ql/ 2) x7Dm 'without the "INT()",s really broken! i !gi%kjMj d`igitsijaS>t?6`bconver32{N , sB of n  sinced is specifZi`hAl, s )()v"F"@0{you jubsype|maimmediate windowDwould R" becDau['ona8 16aVbesuP '/>)!?2{pt'> 8nW= 8 .y = R aS"i0" + H0-), 800b 0<434to (j3?s?S')3up+8 charact0 a imal/5@nA6pp1P&ӡE ѥlresult)h+?`eFBooleae6  ` ]"  F١LenT$p* Sel Case Midb, 1 "@/"9dH"a"q"fAL 00=Jp+_Yh'WBmWf mo0"than:&'s 974 2)`7g>9L@(to "7@Y pthingb_0VB c ` dleuisSi= FaB׳ypoP^procesx"'[AhPZA{\ref 3s, dobkklar1^slK_recursiv0AL Eq) -`M TruRwSpUc@$7= 7 *aB5&=$, - iX1* d 2+e 16 P^ (i1qVal 0%0._!V(Ascda) - 55) End @Selectxresult =  + decdata Next i If@ inverNFalse Thejn|hFob  E>4&H76F 1+If- FunctioZv Publ(ic $ |bin(in As String)a '/M)cos asciiD block to raw Jary (1 byte per 2 characters) scTNDimH iEIntegerCoutOOKX@9;p @ all nonLD For i1 To LeGu Ca@Mid{, i, F1D"0"A"@9", "afAF"G=I+ RI'ensure even numbvofI5@2) Mod{ A-+C"GD- 1ep 23 p=Wr+ Chr( t(A6"1%2))& U@/d nAlpMqsha1! (keyI, ?st:Lthis @needed@o excel becau`Git doesOt acceptw8Q)6'`(xts so hasa|Xbe ne at modul(e l`Blwith) pass7~rrba#spreadsheet (Wh@ich tr@atthe@ a  firsc8?*$ 8@!8,RtoCdnGO]:H]:]:]:]:]\5ltF((kjl MH@ `1t6(5 jdZ!tMH@( (`1t5(ltJtMH@( (xx:8]:H ]\;p^ctMH@( (`t^ qltlli `#pO2tp6(p^5xtMH@( (`1t5( ltJpr qljkrch0((krkjtMH@ `1d6(ldCdldZ!ld t\kjo\q`ld%ld pZkjkZ7q`/d lll`ql jdh k^llqxllqx$8 dxtd tp(lr Jch%(8krl MX@( (58L:H]:X]:]:]:]:]\5ltF(8krl MX@( (`1t68(5 rdhltJR lt*1trltJkaU(8krtMX@( (`ǐ^ q|llFl| `1l/68( rellCxl4xtl 8(d("l 1p>ptl 1x/t ((xtp  9 J@\l >(@J@l\@lM@ `1P66?c?(k6PM@ __SRP_3 &_VBA_PROJECT1dirp__SRP_0|((,`((,`(&,!`(&,I`(&,q`(&,` (&(`0( `0, `a00p 4d @^@a^  *\G{000204EF-0000-0000-C000-000000000046}#3.0#9#C:\Program Files\Common Files\Microsoft Shared\VBA\VBA332.dll#Visual Basic For Applications *\G{00020813-0000-0000-C000-000000000046}#1.2#0#C:\Program Files\Microsoft Office\Office\EXCEL8.OLB#Microsoft Excel 8.0 Object Library*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation*\G{C045313A-9BBF-4B7E-947A-3EE468F586C0}#2.0#0#C:\WINDOWS\system32\MSFormrU~}  I a y  9  q i IqA Y p t  0RyZ`n`ܼ`b`Q Jc%(kl M@ 5L:]:]x:X]:h]H:(]:8]\ 5lFx(kl M@ `165 dfF:N   lF `16<(M@ `^ `/6<(M@ `^ `/6<( M@ `^ `/6<(M@ `^ `/6#EgܺvT2+JY^qX(F `'6"@J@®?pV9 FkV  `'6(F `'6(F `'6(F `'6(F `'6C+X  F('" `'6C+X  F('" `'6C+X  F('" `'6,FlX `'6 J@\l >(@J@l\@lM@ `1P66?c?(k6PM@ `#  k68/6 6d>4cG$+k48Y^k40k4+k48Y^k40k4+k48Y^k4#k4k48k4 4d4OcT+k4k4k4k4Y  "k45 4dVqqqq q4Oct k4pkv+  "Y^qk4@lY^q`@lY^qllll YlY^q5+ k's+  "Y^qk4@lY^q`@lY^qlll YlY^q5+ k(;}+  "Y^qk4@lY^q`@lY^qllll ll YlY^q5+ kstdole h%^*\G{00020430-C 0046}#2.0#0#C:\WINDOWS\syst em32\e2.tlb#OLE Automation`MSForms>SFFrms/| rGC045313A-9BBF-4B7E-947A-3EE468F586C0G4.TWD#Microsoft > b Ob Library:Q039B8C91-5EFD-4E29-8E89-50TC5D69ABQDOCUME~1\JOHNTALOCALSTemp \VBE\E-EXg-.E .`M ~Offic~Of@ic~012DF8D04C-5BFA-101B-BDE5~AA}421gram Files\ V\MSO9`7.DLL_ (8.0R_"ĩThisWorkbookN2@1*Ti@W’kbok(HB1XB,BpT"B+BS@heet12S@e@Pt1dK`odule 2$bosFus1 4?!bK)^rU~~~~~~~~~~~~~~~~~Q : OO r]M    A  ay 1Qq   ThisWorkbookSheet1Module1 VBAProjectF=C:\Program Files\Common Files\Microsoft Shared\VBA\VBA332.dllVBA ! I(F 3C:\Program Files\Microsoft Office\Office\EXCEL8.OLBExcel 9a80FC:\WINDOWS\system32\stdole2.tlbstdole i32shiftleft AiH:1E~Kz>hC:\WINDOWS\system32\MSForms.TWDMSForms aAX.E .`M ^)NP|]i 2C:\DOCUME~1\JOHNTA~1\LOCALS~1\Temp\VBE\MSForms.EXD iAhL-[DR 2C:\Program Files\Microsoft Office\Office\MSO97.DLLOffice Yxsha1i32addi32sub i32rotatelefti32rotateright i32shiftrightdectohexhextodechextobinsha1hex  VBA332.DLL x  0 9 a f A F ` k i  7 =    E 0  H _ `   00000000NrU keydatamessageoperandaoperandbdatainbitcount hexdigits[__SRP_1 PROJECTwmVPROJECT SummaryInformation(ThisWorkbookThisWorkbookSheet1Sheet1Module1Module1ID="{66EC5C4B-20E3-4282-843F-DF0EBBAA5AE3}" Document=ThisWorkbook/&H00000000 Document=Sheet1/&H00000000 Module=Module1 Name="VBAProject" HelpContextID="0" CMG="090B191F1D1F1D1F1D1F1D" DPB="121002290A2A0A2A0A" GC="1B190B2015211521EA" [Host Extender Info] &H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000 [Workspace] ThisWorkbook=0, 0, 0, 0, C Sheet1=44, 44, 906, 516, Module1=22, 22, 884, 494, Oh+'08@Th  John Taylor John TaylorMicrosoft Excel@%ec(՜.+,D՜.+, PXd lt| TESj DocumentSummaryInformation8CompObjf Sheet1  Worksheets 6> _PID_GUIDAN{95A76F4F-29BA-4652-B65D-6933A068B55D} FMicrosoft Excel WorksheetBiff8Excel.Sheet.89q