{"id":366,"date":"2008-05-23T04:06:21","date_gmt":"2008-05-23T04:06:21","guid":{"rendered":"http:\/\/6teen.ru\/?p=34"},"modified":"2008-05-23T04:06:21","modified_gmt":"2008-05-23T04:06:21","slug":"7569","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=366","title":{"rendered":"md5 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435"},"content":{"rendered":"<p>md5 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>md5 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\n\n\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445\nFunction md5(s:string):string;\nvar a:array[0..15] of byte;\ni:integer;\n\nLenHi, LenLo: longword;\nIndex: DWord;\nHashBuffer: array[0..63] of byte;\nCurrentHash: array[0..3] of DWord;\n\nprocedure Burn;\nbegin\nLenHi:= 0; LenLo:= 0;\nIndex:= 0;\nFillChar(HashBuffer,Sizeof(HashBuffer),0);\nFillChar(CurrentHash,Sizeof(CurrentHash),0);\nend;\n\nprocedure Init;\nbegin\nBurn;\nCurrentHash[0]:= $67452301;\nCurrentHash[1]:= $efcdab89;\nCurrentHash[2]:= $98badcfe;\nCurrentHash[3]:= $10325476;\nend;\n\nfunction LRot32(a, b: longword): longword;\nbegin\nResult:= (a shl b) or (a shr (32-b));\nend;\n\nprocedure Compress;\nvar\nData: array[0..15] of dword;\nA, B, C, D: dword;\nbegin\nMove(HashBuffer,Data,Sizeof(Data));\nA:= CurrentHash[0];\nB:= CurrentHash[1];\nC:= CurrentHash[2];\nD:= CurrentHash[3];\n\nA:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 0] + $d76aa478,7);\nD:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 1] + $e8c7b756,12);\nC:= D + LRot32(C + (B xor (D and (A xor B))) + Data[ 2] + $242070db,17);\nB:= C + LRot32(B + (A xor (C and (D xor A))) + Data[ 3] + $c1bdceee,22);\nA:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 4] + $f57c0faf,7);\nD:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 5] + $4787c62a,12);\nC:= D + LRot32(C + (B xor (D and (A xor B))) + Data[ 6] + $a8304613,17);\nB:= C + LRot32(B + (A xor (C and (D xor A))) + Data[ 7] + $fd469501,22);\nA:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 8] + $698098d8,7);\nD:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 9] + $8b44f7af,12);\nC:= D + LRot32(C + (B xor (D and (A xor B))) + Data[10] + $ffff5bb1,17);\nB:= C + LRot32(B + (A xor (C and (D xor A))) + Data[11] + $895cd7be,22);\nA:= B + LRot32(A + (D xor (B and (C xor D))) + Data[12] + $6b901122,7);\nD:= A + LRot32(D + (C xor (A and (B xor C))) + Data[13] + $fd987193,12);\nC:= D + LRot32(C + (B xor (D and (A xor B))) + Data[14] + $a679438e,17);\nB:= C + LRot32(B + (A xor (C and (D xor A))) + Data[15] + $49b40821,22);\n\nA:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 1] + $f61e2562,5);\nD:= A + LRot32(D + (B xor (C and (A xor B))) + Data[ 6] + $c040b340,9);\nC:= D + LRot32(C + (A xor (B and (D xor A))) + Data[11] + $265e5a51,14);\nB:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 0] + $e9b6c7aa,20);\nA:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 5] + $d62f105d,5);\nD:= A + LRot32(D + (B xor (C and (A xor B))) + Data[10] + $02441453,9);\nC:= D + LRot32(C + (A xor (B and (D xor A))) + Data[15] + $d8a1e681,14);\nB:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 4] + $e7d3fbc8,20);\nA:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 9] + $21e1cde6,5);\nD:= A + LRot32(D + (B xor (C and (A xor B))) + Data[14] + $c33707d6,9);\nC:= D + LRot32(C + (A xor (B and (D xor A))) + Data[ 3] + $f4d50d87,14);\nB:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 8] + $455a14ed,20);\nA:= B + LRot32(A + (C xor (D and (B xor C))) + Data[13] + $a9e3e905,5);\nD:= A + LRot32(D + (B xor (C and (A xor B))) + Data[ 2] + $fcefa3f8,9);\nC:= D + LRot32(C + (A xor (B and (D xor A))) + Data[ 7] + $676f02d9,14);\nB:= C + LRot32(B + (D xor (A and (C xor D))) + Data[12] + $8d2a4c8a,20);\n\nA:= B + LRot32(A + (B xor C xor D) + Data[ 5] + $fffa3942,4);\nD:= A + LRot32(D + (A xor B xor C) + Data[ 8] + $8771f681,11);\nC:= D + LRot32(C + (D xor A xor B) + Data[11] + $6d9d6122,16);\nB:= C + LRot32(B + (C xor D xor A) + Data[14] + $fde5380c,23);\nA:= B + LRot32(A + (B xor C xor D) + Data[ 1] + $a4beea44,4);\nD:= A + LRot32(D + (A xor B xor C) + Data[ 4] + $4bdecfa9,11);\nC:= D + LRot32(C + (D xor A xor B) + Data[ 7] + $f6bb4b60,16);\nB:= C + LRot32(B + (C xor D xor A) + Data[10] + $bebfbc70,23);\nA:= B + LRot32(A + (B xor C xor D) + Data[13] + $289b7ec6,4);\nD:= A + LRot32(D + (A xor B xor C) + Data[ 0] + $eaa127fa,11);\nC:= D + LRot32(C + (D xor A xor B) + Data[ 3] + $d4ef3085,16);\nB:= C + LRot32(B + (C xor D xor A) + Data[ 6] + $04881d05,23);\nA:= B + LRot32(A + (B xor C xor D) + Data[ 9] + $d9d4d039,4);\nD:= A + LRot32(D + (A xor B xor C) + Data[12] + $e6db99e5,11);\nC:= D + LRot32(C + (D xor A xor B) + Data[15] + $1fa27cf8,16);\nB:= C + LRot32(B + (C xor D xor A) + Data[ 2] + $c4ac5665,23);\n\nA:= B + LRot32(A + (C xor (B or (not D))) + Data[ 0] + $f4292244,6);\nD:= A + LRot32(D + (B xor (A or (not C))) + Data[ 7] + $432aff97,10);\nC:= D + LRot32(C + (A xor (D or (not B))) + Data[14] + $ab9423a7,15);\nB:= C + LRot32(B + (D xor (C or (not A))) + Data[ 5] + $fc93a039,21);\nA:= B + LRot32(A + (C xor (B or (not D))) + Data[12] + $655b59c3,6);\nD:= A + LRot32(D + (B xor (A or (not C))) + Data[ 3] + $8f0ccc92,10);\nC:= D + LRot32(C + (A xor (D or (not B))) + Data[10] + $ffeff47d,15);\nB:= C + LRot32(B + (D xor (C or (not A))) + Data[ 1] + $85845dd1,21);\nA:= B + LRot32(A + (C xor (B or (not D))) + Data[ 8] + $6fa87e4f,6);\nD:= A + LRot32(D + (B xor (A or (not C))) + Data[15] + $fe2ce6e0,10);\nC:= D + LRot32(C + (A xor (D or (not B))) + Data[ 6] + $a3014314,15);\nB:= C + LRot32(B + (D xor (C or (not A))) + Data[13] + $4e0811a1,21);\nA:= B + LRot32(A + (C xor (B or (not D))) + Data[ 4] + $f7537e82,6);\nD:= A + LRot32(D + (B xor (A or (not C))) + Data[11] + $bd3af235,10);\nC:= D + LRot32(C + (A xor (D or (not B))) + Data[ 2] + $2ad7d2bb,15);\nB:= C + LRot32(B + (D xor (C or (not A))) + Data[ 9] + $eb86d391,21);\n\nInc(CurrentHash[0],A);\nInc(CurrentHash[1],B);\nInc(CurrentHash[2],C);\nInc(CurrentHash[3],D);\nIndex:= 0;\nFillChar(HashBuffer,Sizeof(HashBuffer),0);\nend;\n\nprocedure Update(const Buffer; Size: longword);\nvar\nPBuf: ^byte;\nbegin\nInc(LenHi,Size shr 29);\nInc(LenLo,Size*8);\nif LenLo< (Size*8) then\nInc(LenHi);\n\nPBuf:= @Buffer;\nwhile Size> 0 do\nbegin\nif (Sizeof(HashBuffer)-Index)<= DWord(Size) then\nbegin\nMove(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);\nDec(Size,Sizeof(HashBuffer)-Index);\nInc(PBuf,Sizeof(HashBuffer)-Index);\nCompress;\nend\nelse\nbegin\nMove(PBuf^,HashBuffer[Index],Size);\nInc(Index,Size);\nSize:= 0;\nend;\nend;\nend;\n\nprocedure Final(var Digest);\nbegin\nHashBuffer[Index]:= $80;\nif Index>= 56 then Compress;\nPDWord(@HashBuffer[56])^:= LenLo;\nPDWord(@HashBuffer[60])^:= LenHi;\nCompress;\nMove(CurrentHash,Digest,Sizeof(CurrentHash));\nBurn;\nend;\n\nbegin\nInit;\nUpdate(s[1],Length(s));\nFinal(a);\nresult:='';\nfor i:=0 to 15 do\nresult:=result+IntToHex(a[i],0);\nBurn;\nend;\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>md5 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[364,445],"tags":[543,800],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/366"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=366"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/366\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}