class HashHelper { companion object { fun crc32(file: File): Long { FileInputStream(file).use { fis -> return crc32(file) } } fun crc32(inputStream: InputStream): Long { val hash = CRC32() BufferedInputStream(inputStream).use { input -> val buffer = ByteArray(1024 * 16) var size: Int do { size = input.read(buffer) if (size > 0) { hash.update(buffer, 0, size) } } while (size != -1) } return hash.value } }}
❤️ Is this article helpful?
Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.
Do send some 💖 to @d_luaz or share this article.
✨ By Desmond Lua
A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz
👶 Apps I built
Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.