Skip to content

Instantly share code, notes, and snippets.

@varantes
Last active April 7, 2024 18:01
Show Gist options
  • Save varantes/0ff5a120a4e56be3057d8dfd89678e07 to your computer and use it in GitHub Desktop.
Save varantes/0ff5a120a4e56be3057d8dfd89678e07 to your computer and use it in GitHub Desktop.
Generates CRC32 hash for image files using Kotlin
import java.nio.file.Files
import java.nio.file.Paths
import java.util.zip.*
val crc32 = CRC32()
crc32.update(Files.readAllBytes(Paths.get("C:\\Users\\valdemar.neto\\Documents\\Certibio\\temp\\1\\data_10.png")))
val crc10 = crc32.value
crc32.reset()
crc32.update(Files.readAllBytes(Paths.get("C:\\Users\\valdemar.neto\\Documents\\Certibio\\temp\\1\\data_11.png")))
val crc11 = crc32.value
crc32.reset()
crc32.update(Files.readAllBytes(Paths.get("C:\\Users\\valdemar.neto\\Documents\\Certibio\\temp\\1\\data_12.png")))
val crc12 = crc32.value
println("$crc10 $crc11 $crc12")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment