begin lMessageLength := Length(sMessage); lNumberOfWords := (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) div BITS_TO_A_BYTE)) div (MODULUS_BITS div BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS div BITS_TO_A_WORD); SetLength(lWordArray, lNumberOfWords); lByteCount := 0; While lByteCount < lMessageLength do begin lWordCount := lByteCount div BYTES_TO_A_WORD; lBytePosition := (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE; lWordArray[lWordCount] := lWordArray[lWordCount] Or longword(Asc(sMessage[lByteCount + 1]) shl lBytePosition); lByteCount := lByteCount + 1; end; lWordCount := lByteCount div BYTES_TO_A_WORD; lBytePosition := (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE; lWordArray[lWordCount] := lWordArray[lWordCount] or ($80 shl lBytePosition); lWordArray[lNumberOfWords - 2] := lMessageLength shl 3; lWordArray[lNumberOfWords - 1] := lMessageLength shr 29; Result := lWordArray; end; class function sMD5.ConvToWord(const sMessage: string): arrlongword; begin Result := ConvToWord(WideString(sMessage)); end; class function sMD5.MD5(const sMessage: string; const sType: boolean = false): string; const S11 = 7; S12 = 12; S13 = 17; S14 = 22; S21 = 5; S22 = 9; S23 = 14; S24 = 20; S31 = 4; S32 = 11; S33 = 16; S34 = 23; S41 = 6; S42 = 10; S43 = 15; S44 = 21; |