Created
August 2, 2018 00:08
-
-
Save aziascreations/b152bb98c54c2216245436b5976a1943 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
OpenConsole() | |
Procedure CRC16CCITT(*mem.Ascii,len) | |
Protected crc.u = $FFFF; | |
While a < len | |
For i = 0 To 7 | |
bit = (*mem\a >> (7-i) & 1) | |
c15 = ((crc >> 15) & 1) | |
crc << 1 | |
If Bool(c15 ! bit) | |
crc ! $1021 | |
EndIf | |
Next | |
a+1 | |
*mem+1 | |
Wend | |
crc & $ffff | |
ProcedureReturn crc | |
EndProcedure | |
Procedure.q Hex2Dec(Hex.s) | |
Protected result.q, n, temp, pow.q=1 | |
hex=UCase(hex) | |
For n=MemoryStringLength(@Hex)-1 To 0 Step -1 | |
temp=PeekC(@Hex+n*SizeOf(Character))-48 | |
If temp >= 17 And temp <= 22 | |
temp-7 | |
ElseIf temp < 0 Or temp > 9 | |
Break | |
EndIf | |
result+temp*pow | |
pow*16 | |
Next | |
ProcedureReturn result | |
EndProcedure | |
Dim Results.q(65536) | |
Global Tmp.s{8} = "_" | |
If CreateFile(0, "out-crc16ccitt-"+FormatDate("%yyyy-%mm-%dd-%hh-%ii-%ss", Date()) + ".txt") | |
Debug "Hashing from #10000000 to #FFFFFFFF..." | |
PrintN("Hashing from #10000000 to #FFFFFFFF...") | |
For i=Hex2Dec("$10000000") To Hex2Dec("$FFFFFFFF") | |
Tmp = Hex(i, #PB_Quad) | |
Index.u = CRC16CCITT(Ascii(Tmp),Len(Tmp)) | |
Results(Index) = Results(Index) + 1 | |
Next | |
Debug "List of most common crc16 hashes in .u type..." | |
PrintN("List of most common crc16 hashes in .u type...") | |
For i=0 To ArraySize(Results()) | |
If Results(i) >= 1000 | |
WriteStringN(0, Str(i) + " | " + Hex(i, #PB_Unicode) + " -> " + Results(i)) | |
EndIf | |
Next | |
WriteStringN(0, #CRLF$+"- - - - - - - - - - - - - - - - - - - - - -"+#CRLF$) | |
For i=0 To ArraySize(Results()) | |
If Results(i) >= 10000 | |
WriteStringN(0, Str(i) + " | " + Hex(i, #PB_Unicode) + " -> " + Results(i)) | |
EndIf | |
Next | |
WriteStringN(0, #CRLF$+"- - - - - - - - - - - - - - - - - - - - - -"+#CRLF$) | |
For i=0 To ArraySize(Results()) | |
If Results(i) >= 100000 | |
WriteStringN(0, Str(i) + " | " + Hex(i, #PB_Unicode) + " -> " + Results(i)) | |
EndIf | |
Next | |
Debug "Closing file..." | |
PrintN("Closing file...") | |
CloseFile(0) | |
Else | |
PrintN("Error: can't write the file") | |
End | |
EndIf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment