Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
46
Task/CRC-32/FutureBasic/crc-32.basic
Normal file
46
Task/CRC-32/FutureBasic/crc-32.basic
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// CRC_32 Checksum
|
||||
//
|
||||
// FutureBasic 7.0.34, August 2025 R.W
|
||||
//----------------------------------------------
|
||||
|
||||
// Get CRC_32 checksum from a CFstring
|
||||
// using the standard bits reversed 0x04C11DB7
|
||||
|
||||
// Verified accuracy using the site
|
||||
// https://codeshack.io/crc32-checksum-generator/
|
||||
|
||||
local fn getCRC_32 (textStr As CFStringRef) As UInt32
|
||||
UInt32 i, j, crc, byte
|
||||
crc = 0xFFFFFFFF
|
||||
|
||||
for i = 0 to len(textStr) -1
|
||||
byte = ucc(textStr, i)
|
||||
crc = crc XOR byte
|
||||
for j = 0 to 7
|
||||
if ( crc AND 1 )
|
||||
crc = (crc >> 1) XOR 0xEDB88320
|
||||
else
|
||||
crc = crc >> 1
|
||||
end if
|
||||
next
|
||||
next
|
||||
crc = crc XOR 0xFFFFFFFF
|
||||
end fn = crc
|
||||
|
||||
|
||||
window 1,@"CRC checksum"
|
||||
|
||||
CFStringRef testString
|
||||
testString = @"The quick brown fox jumps over the lazy dog"
|
||||
|
||||
UInt32 checksum
|
||||
checksum = fn getCRC_32(testString)
|
||||
|
||||
print
|
||||
print @" ";testString
|
||||
print @" has a checksum of ";hex(checksum)
|
||||
|
||||
handleEvents
|
||||
|
||||
//
|
||||
Loading…
Add table
Add a link
Reference in a new issue