VB's CRC32 Check code

Source: Internet
Author: User
Tags crc32

These days to write CRC32 VB code, tested on the Web CRC32 verification results are identical.

Option Explicit Dim crc32table (255) As Long Private Sub Command1_Click () Dim strhex As String Dim i as Long Dim buffer () as Byte strhex = "AA 1C 2A 00", 9D B4, B0, F8 20 00 00 10 00 00 01 00 00  xx xx xx 8E 3D F1 B2, C3 7B 0F---------------E5 D4 3B 6D D4 3B 0 7F 3C (4) xx xx (3F) FC 6C-one-one-one-one-one-one-one-off-one-one-one---------------------- 0.9D B4 4 A F8 the xx xx xx xx 56 xx 43 40 19 DD E4 5A (B2)-----  C3, 5D, E0 CC D9, 3D 00, 00, 8C DA 3B, 8C da 3B B6, 00, 3C 30 30 30 34 2C 6D 4 B "ReDim buffer (Len (Strhex) \ 3) For i = 1 to Len (strhex) Step 3 buffer ((i-1)/3) = Val ("&h" & Left (Mid (Strhex, I, 3), 2)) Next ' Open ' C:\ts.bpm ' for Binary as #1 ' Put # 1,, buffer ' Close #1    Text1 = Right ("XX" & Hex (crc32byt (buffer)), 8) ' MsgBox "ok!" End subpublic Function crc32byt (BUF () as Byte) as Long dim i as Long, iCRC as long, Lnga as long, ret as Long Dim B (     As Byte Dim Bytt as Byte, bytc as Byte B = Buf ' StrConv (item, vbfromunicode) ICRC = &hffffffff InitCrc32 For i = 0 to UBound (b) BYTC = B (i) Bytt = (ICRC and &HFF) Xor bytc Lnga = ((ICRC and &hff    FFFF00)/&h100) and &hffffff ICRC = Lnga xor crc32table (BYTT) Next ret = ICRC xor &hffffffff Crc32byt = retend function ' CRC32 table This code is CRC32 table public Function InitCrc32 (Optional ByVal Seed as Long = &hedb88320, O Ptional ByVal precondition as Long = &hffffffff) As long Dim I As Integer, J As Integer, Crc32 as Long, Temp as Lon G for i = 0 to 255 CRC32 = i-j = 0 to 7 Temp = ((CRC32 and &hfffffffe)/&H2) and &h7fffffff If (CRC32 and &h1) then Crc32 = Temp Xor Seed Else CRC32 = Temp next crc32table (i) = Crc32 next InitCrc32 = Preconditionend Function 


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

VB's CRC32 Check code

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.