没有合适的资源?快使用搜索试试~ 我知道了~
VB源代码-CRC32自校验
资源推荐
资源详情
资源评论
'类模块(名称为clsCRC)代码
Option Explicit
Public Enum CRCAlgorithms
CRC16
CRC32
End Enum
Private m_Algorithm As Boolean
Private m_CRC16 As Long
Private m_CRC16Asm() As Byte
Private m_CRC16Init As Boolean
Private m_CRC16Table(0 To 255) As Long
Private m_CRC32 As Long
Private m_CRC32Asm() As Byte
Private m_CRC32Init As Boolean
Private m_CRC32Table(0 To 255) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function AddBytes(ByteArray() As Byte) As Variant
Dim ByteSize As Long
On Local Error GoTo NoData
ByteSize = UBound(ByteArray) - LBound(ByteArray) + 1
On Local Error GoTo 0
Select Case m_Algorithm
Case CRC16
Call CallWindowProc(VarPtr(m_CRC16Asm(0)), VarPtr(m_CRC16), VarPtr(ByteArray(LBound(ByteArray))), VarPtr(m_CRC16Table(0)), ByteSize)
Case CRC32
Call CallWindowProc(VarPtr(m_CRC32Asm(0)), VarPtr(m_CRC32), VarPtr(ByteArray(LBound(ByteArray))), VarPtr(m_CRC32Table(0)), ByteSize)
End Select
NoData:
AddBytes = Value
Option Explicit
Public Enum CRCAlgorithms
CRC16
CRC32
End Enum
Private m_Algorithm As Boolean
Private m_CRC16 As Long
Private m_CRC16Asm() As Byte
Private m_CRC16Init As Boolean
Private m_CRC16Table(0 To 255) As Long
Private m_CRC32 As Long
Private m_CRC32Asm() As Byte
Private m_CRC32Init As Boolean
Private m_CRC32Table(0 To 255) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function AddBytes(ByteArray() As Byte) As Variant
Dim ByteSize As Long
On Local Error GoTo NoData
ByteSize = UBound(ByteArray) - LBound(ByteArray) + 1
On Local Error GoTo 0
Select Case m_Algorithm
Case CRC16
Call CallWindowProc(VarPtr(m_CRC16Asm(0)), VarPtr(m_CRC16), VarPtr(ByteArray(LBound(ByteArray))), VarPtr(m_CRC16Table(0)), ByteSize)
Case CRC32
Call CallWindowProc(VarPtr(m_CRC32Asm(0)), VarPtr(m_CRC32), VarPtr(ByteArray(LBound(ByteArray))), VarPtr(m_CRC32Table(0)), ByteSize)
End Select
NoData:
AddBytes = Value
End Function
Public Function AddString(Text As String) As Variant
AddString = AddBytes(StrConv(Text, vbFromUnicode))
End Function
Public Property Let Algorithm(New_Value As CRCAlgorithms)
m_Algorithm = New_Value
Select Case m_Algorithm
Case CRC16
If (Not m_CRC16Init) Then Call InitializeCRC16
Case CRC32
If (Not m_CRC32Init) Then Call InitializeCRC32
End Select
Call Clear
End Property
Public Property Get Algorithm() As CRCAlgorithms
Algorithm = m_Algorithm
End Property
Public Function CalculateBytes(ByteArray() As Byte) As Variant
Call Clear
CalculateBytes = AddBytes(ByteArray)
End Function
Public Function CalculateFile(Filename As String) As Variant
Dim Filenr As Integer
Dim ByteArray() As Byte
If (FileLen(Filename) = 0) Then Exit Function
Public Function AddString(Text As String) As Variant
AddString = AddBytes(StrConv(Text, vbFromUnicode))
End Function
Public Property Let Algorithm(New_Value As CRCAlgorithms)
m_Algorithm = New_Value
Select Case m_Algorithm
Case CRC16
If (Not m_CRC16Init) Then Call InitializeCRC16
Case CRC32
If (Not m_CRC32Init) Then Call InitializeCRC32
End Select
Call Clear
End Property
Public Property Get Algorithm() As CRCAlgorithms
Algorithm = m_Algorithm
End Property
Public Function CalculateBytes(ByteArray() As Byte) As Variant
Call Clear
CalculateBytes = AddBytes(ByteArray)
End Function
Public Function CalculateFile(Filename As String) As Variant
Dim Filenr As Integer
Dim ByteArray() As Byte
If (FileLen(Filename) = 0) Then Exit Function
剩余14页未读,继续阅读
资源评论
panxiguo1733287565
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功