Created
June 24, 2018 06:16
-
-
Save rajat1saxena/738da60a88413a8c5b0bb8f41e31e796 to your computer and use it in GitHub Desktop.
generate_sha512_of_a_file.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun generateChecksum(data: ByteArrayOutputStream): String { | |
try { | |
val digest: MessageDigest = MessageDigest.getInstance("SHA-512") | |
val hash: ByteArray = digest.digest(data.toByteArray()) | |
return printableHexString(hash) | |
} catch (e: Exception) { | |
e.printStackTrace() | |
} | |
return "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment