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

commonMain.at.asitplus.signum.supreme.hash.DigestExtensions.kt Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package at.asitplus.signum.supreme.hash

import at.asitplus.signum.indispensable.Digest
import org.kotlincrypto.hash.sha1.SHA1
import org.kotlincrypto.hash.sha2.SHA256
import org.kotlincrypto.hash.sha2.SHA384
import org.kotlincrypto.hash.sha2.SHA512

operator fun Digest.invoke(): org.kotlincrypto.core.digest.Digest = when(this) {
    Digest.SHA1 -> SHA1()
    Digest.SHA256 -> SHA256()
    Digest.SHA384 -> SHA384()
    Digest.SHA512 -> SHA512()
}
inline fun Digest.digest(data: Sequence) = this().also { data.forEach(it::update) }.digest()
inline fun Digest.digest(bytes: ByteArray) = this().digest(bytes)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy