-
-
Save anonymous/c1206b3e17c6b01a7838 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function CRC16TWICE(s As String) | |
Dim l As Integer, l3 As Integer | |
Dim s1 As String, s2 As String, s3 As String | |
l = Int(Len(s) / 2) | |
s1 = Mid(s, 1, l) | |
s2 = Mid(s, l + 1, l + 1) | |
CRC16TWICE = hash4(s1) + hash4(s2) | |
End Function | |
Function hash4(txt) | |
Dim x As Long | |
Dim mask, i, j, nC, crc As Integer | |
Dim c As String | |
crc = &HFFFF | |
For nC = 1 To Len(txt) | |
j = asc(Mid(txt, nC)) | |
crc = crc Xor j | |
For j = 1 To 8 | |
mask = 0 | |
If crc / 2 <> Int(crc / 2) Then mask = &HA001 | |
crc = Int(crc / 2) And &H7FFF: crc = crc Xor mask | |
Next j | |
Next nC | |
c = Hex$(crc) | |
While Len(c) < 4 | |
c = "0" & c | |
Wend | |
hash4 = c | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment