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

love.forte.simbot.utils.Digest.kt Maven / Gradle / Ivy

There is a newer version: 3.0.0.preview.0.4
Show newest version
package love.forte.simbot.utils

import java.security.MessageDigest



public typealias Digest = MessageDigest



public fun digest(algorithm: String): Digest = Digest.getInstance(algorithm)


public inline fun digest(algorithm: String, block: Digest.() -> Unit): ByteArray =
    digest(algorithm).also(block).digest()


public inline fun md5(block: Digest.() -> Unit): ByteArray = digest("md5", block)










public fun ByteArray.toHex(): String {
    return buildString {
        [email protected] { b ->
            val str = (b.toInt() and 0xff).toString(16)
            if (str.length == 1) {
                append('0')
            }
            append(str)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy