Skip to content

Instantly share code, notes, and snippets.

/CRC16 Secret

Created February 7, 2013 11:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anonymous/d24a7a03f7f2a771c0f2 to your computer and use it in GitHub Desktop.
Save anonymous/d24a7a03f7f2a771c0f2 to your computer and use it in GitHub Desktop.
Function CRC16HASH(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, 1))
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
CRC16HASH = Hex$(crc)
End Function
@lw-bmc
Copy link

lw-bmc commented Feb 1, 2019

Hi,

Thanks for uploading this, very helpful.

I'm trying to verify the result from your function using the CRC calculator at http://www.zorc.breitbandkatze.de/crc.html

I'm unable to work out what the initial value and CRC polynomial values used in your code are. Could you please tell me how I can verify the resulting hash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment