mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Add update-crc version for crc32 function with Data argument
This commit is contained in:
@@ -18,8 +18,8 @@ struct CheckSums {
|
||||
return ~crc
|
||||
}
|
||||
|
||||
static func crc32(_ data: Data) -> UInt32 {
|
||||
var crc: UInt32 = ~0
|
||||
static func crc32(_ data: Data, prevValue: UInt32 = 0) -> UInt32 {
|
||||
var crc = ~prevValue
|
||||
for i in 0..<data.count {
|
||||
let index = (crc & 0xFF) ^ (UInt32(data[i]))
|
||||
crc = CheckSums.crc32table[Int(index)] ^ (crc >> 8)
|
||||
|
||||
Reference in New Issue
Block a user