-
Notifications
You must be signed in to change notification settings - Fork 145
Checksums
Rajesh R edited this page Jun 16, 2024
·
1 revision
One liner checksum for files:
file.md5() // equivalent to file.checksum("md5")
file.sha1()
file.sha256()
file.sha512()
Note: The above also works for directories (it recursively computes for each file in the directory).
For input/output streams:
val md5: String = inputstream.md5.hexDigest()
val md5: String = outputstream.md5.hexDigest()
The above consumes and closes the inputstream
. If you want to write it to a file AND also compute the sha512
, you can do:
val md5: String = inputstream.sha512.hexDigest(drainTo = someFile)