简体   繁体   中英

Generate CRC32 checksum of file swift

I have a.zip file inside the project and I am transferring it to the external ESP32 via Bluetooth. But I need to send the CRC-32 checksum at the end of the sending file. I don't have any idea how to generate it.

Can anyone help me with how to do it in the right way?

Thanks in advance.

So, I have found one amazing framework called CryptoSwift. This made my day. Here is how

  • Get file Data from the file path.

I have a function which returns Data from file name and type. And CryptoSwift has the extension of Data which converts the crc32 by calling simply .crc32()

and than call crc32()

let crcChecksum = Utils.sharedInstance.getFileData(forResource: "firmware", withExtension: "bin").crc32()

For mote detail.

https://github.com/krzyzanowskim/CryptoSwift

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM