iOS的CRC8算法

https://github.com/DingSoung/CRC/tree/d6eadb1ecc6f62c2ba7308ca061041bebd7b7f62

final class CRC8 {
    
    static let poly = 0x07
    static let mask = 0xff
    
    static let table: [UInt8] = {
        
        var table = Array.init(repeating: UInt8(0), count: 256)
        
        for i in 0.. UInt8 {
        guard let data = string.data(using: String.Encoding.utf8) else { return 0 }
        return makeCRC8(data: data)
    }
    
    static func makeCRC8(data: Data) -> UInt8 {
        let dataArray = [UInt8](data)
        var crc8:UInt8 = 0x00
        for i in 0.. UInt8 {
        
        var crc8:UInt8 = 0x00
        for i in 0..

你可能感兴趣的:(iOS的CRC8算法)