https://kotlinlang.org logo
#announcements
Title
# announcements
c

chb0kotlin

06/09/2017, 6:16 PM
Copy code
private fun hash(f: File): String {
        MessageDigest.getInstance(hashAlgo)?.let {
            FileInputStream(f).let { f ->
                IOUtils.copy(f, DigestOutputStream(NullOutputStream(), it))
                f.close()
            }
            it.digest().map { String.format("%02x",it) }.reduce{String::plus}
        }
        throw RuntimeException("Something went wrong")
    }
n

nkiesel

06/10/2017, 12:08 AM
chb0kotlin: it.digest().map { "%02x".format(it) }.joinToString("")
9 Views