All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.java.security.MessageDigest.kt Maven / Gradle / Ivy

package name.remal

import java.io.InputStream
import java.security.MessageDigest

fun MessageDigest.update(data: InputStream) {
    val buffer = ByteArray(1024)
    while (true) {
        val read = data.read(buffer, 0, buffer.size)
        if (read < 0) break
        update(buffer, 0, read)
    }
}

fun MessageDigest.digestHex(data: ByteArray) = encodeHex(digest(data))
fun MessageDigest.digestHex() = encodeHex(digest())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy