secretblob.SecretBlobKey.kt Maven / Gradle / Ivy
package se.wollan.crypto.secretblob
interface SecretBlobKey {
val length: Int
/** Must be same number of bytes as length L, so in hex terms that means 2L. */
val hexMask: String
}
internal fun SecretBlobKey.withMask(hexMask: String): SecretBlobKey {
require(length * 2 == hexMask.length) { "new hex mask must of of length $length" }
val orig = this
return object : SecretBlobKey {
override val length: Int = orig.length
override val hexMask: String = hexMask
override fun equals(other: Any?): Boolean = orig == other
override fun hashCode(): Int = orig.hashCode()
}
}