鏀惰棌 (0) +1 璧� (0) +1 韪� (0) +1
鏀惰棌鎴愬姛鏌ョ湅鏀惰棌>>

正在阅读:和md5.asp结果一样的Delphi加密代码和md5.asp结果一样的Delphi加密代码

2004-07-23 10:16 出处:CSDN 作者:ScriptBaby 责任编辑:linjixiong

 


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;

 


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
鎵嬫満璁块棶鍥炲埌椤堕儴