Delphi-CRC32 Verification

Source: Internet
Author: User
Tags crc32

an online down unit. I changed it myself.

Unit utcrc32; interfaceuses windows, sysutils, classes; const // CRC32 table crc32tab: array [0 .. $ ff] of longint = ($00000000, $77073096, $ ee0e612c, $ 990951ba, $076dc419, $ 706af48f, $ scheme, $ scheme, $0edb8832, $79dcb8a4, $ scheme, $97d2d988, $ variable, $ 7eb17cbd, $ variable, $90bf1d91, $1db71064, $6ab020f2, $ f3b97148, $ 84be41de, $ variable, $83d1_c7, $ scheme, $646ba8c0, $ fd62f97a, $ 8a65c9ec, $ 14015c4f, $63066cd9, $ fa0f3d63, $ scheme, $ scheme, $ 4c69105e, $ d56041e4, $ scheme, $ Scheme, $ scheme, $ d20d85fd, $ a50ab56b, $ scheme, $ 42b2986c, $ dbbbc9d6, $ scheme, $ 32d86pushed, $45df5c75, $ scheme, $ scheme, $ 26d930ac, $ 51de003a, $ response, $ bfd06116, $ response, $56b3c423, $ cfba9599, $ response, $ 2802b89e, $5f058808, $ c60cd9b2, $ b10be924, $ response, $58684c11, $ response, $ scheme, $76dc4190, $01db7106, $ 98d220bc, $ efd5102a, $71b18589, $ scheme, $9fbfe4a5, $ scheme, $7807c9a2, $ scheme, $ scheme, $ e10e9818, $ region, $ 086d3d2d, $91646c97, $ e6635c01, $ region, $1c6c6162, $ region, $ f262004e, $ 6c0695ed, $ region, $ region, $ f50fc457, $65b0d9c6, $ response, $ 62dd1ddf, $15da2d49, $8cd37cf3, $ fbd44c65, $4db26158, $ 3ab551ce, $ a3bc0074, $ d4bb30e2, $ response, $ response, $ region, $ region, $ 4369e96a, $ 346ed9fc, $ ad678846, $ region, $ region 42d73, $33031de5, $ aa0a4c5f, $ region, $ 5005713c, $ 270241aa, $ be0b1010, $ scheme, $5768b525, $206f85b3, $ scheme, $ ce61e49f, $ scheme, $29d9c998, $ scheme, $ scheme, $59b33d17, $2eb40d81, $ b7bd5c3b, $ c0ba6cad, $ scheme, $9abfb3b6, $ scheme, $ scheme, $ ead54739, $ 9dd277af, $04db2615, $73dc1683, $ e3630b12, $94643b84, $ scheme, $ scheme, $ e40ecf0b, $ scheme, $0a00ae27, $ scheme, $ scheme, $8708a3d2, $ scheme, $ 6906c2fe, $ f762575d, $ 806567cb, $196c3671, $ scheme, $ fed41b76, $89d32be0, $ response, $ 67dd4acc, $ response, $8ebeeff9, $17b7be43, $60b08ed5, $ response, $ a1d1937e, $38d8c2c4, $4fdff252, $ d1bb67f1, $ response, $ response, $ 48b2364b, $ d80d2133, $ af0a1b4c, $36034af6, $10947a60, $ df60efc3, $ a867df55, $ 109e8eef, $4669be79, $ scheme, $ scheme, $ scheme, $220216b9, $ 5505262f, $ c5ba3bbe, $ b2bd0b28, $2bb45a92, $5cb36a04, $ c2d7ffa7, $ scheme, $ 2cd99e8b, $ scheme, $ Scheme, $ ec63f226, $ 756aa39c, $ 026d930a, $9c0906a9, $ hour, $72076785, $05005713, $95bf4a82, $ e2b87a14, $ 7bb12bae, $0cb61b38, $ hour, $ hour, $ videos, $0bdbdf21, $86d3d2d4, $ videos, $68ddb3f8, $ videos, $ 81be16cd, $ videos, $6fb077e1, $18b74777, $88085ae6, $ videos, $ 66063bca, $ 11010b5c, $ response, $ f862ae69, $616bffd3, $166ccf45, $ a00ae278, $ d70dd2ee, $ response, $3903b3c2, $ a7672661, $ response, $ 4969474d, $ response, $ scheme, $ d9d65adc, $40df0b66, $37d83bf0, $ scheme, $ debb9ec5, $ 47b2cf7f, $ scheme, $ bdbdf21c, $ cabac28a, $ scheme, $ scheme, $ bad03605, $ scheme, $54de5729, $ 23d967bf, $ b3667a2e, $ c4614ab8, $ scheme, $2a6f2b94, $ b40bbe37, $ scheme); Procedure getcrc32stream (astream: tstream; var CRC32: Cardinal); implementationfunction updatecrc32 (initcrc: longint; var buffer; {$ ifdef Win32} length: longint {$ else} length: Word {$ endif }): longint; begin ASM {$ ifdef Win32} Push ESI push EDI push eax push EBX push ECx push edX Lea EDI, crc32tab mov ESI, buffer mov ax, word PTR initcrc mov dx, word PTR initcrc + 2 mov ECx, length or ECX, ECx JZ @ done @ loop: xor ebx, EBX mov BL, Al lodsb xor bl, Al mov Al, ah mov ah, DL mov DL, dh xor dh, dh shl bx, 1 shl bx, 1 add EBX, edi xor ax, [EBX] XOR dx, [EBX + 2] loop @ done: mov word PTR result, ax mov word PTR result + 2, DX pop edX pop ECx pop EBX pop eax pop EDI pop ESI {$ else} push ds pop es push ds Lea Di, crc32tab lDs Si, buffer mov ax, word PTR initcrc mov dx, word PTR initcrc + 2 mov CX, length or CX, cx jz @ done @ loop: xor bh, BH mov BL, Al lodsb xor bl, Al mov Al, ah mov ah, DL mov DL, dh xor dh, dh shl bx, 1 shl bx, 1 XOR ax, ES: [di + BX] XOR dx, ES: [di + bx + 2] loop @ done: Pop DS mov word PTR result, ax mov word PTR result + 2, DX {$ endif} end; procedure getcrc32stream (astream: tstream; var CRC32: Cardinal); var Buffer: pbyte; N: int64; begin n: = astream. size; getmem (buffer, n); try CRC32: = updatecrc32 ($ ffffffff, buffer ^, n) Finally freemem (buffer, n); end; CRC32: = Not CRC32; end; end.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.