INNER CODE UNIT · Kotlin
signWithNonRandomKeys
terl/lazysodium-java · sample-app/src/main/kotlin/Main.kt:72
private fun signWithNonRandomKeys() {
val msg = "Sign this"
val pk: Key = Key.fromPlainString("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav8888888888")
val sk: Key = Key.fromPlainString("edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh8888888888")
log()
printStep(
"2",
"Signing a message (non-random)",
("We will be using the non-random secret key '" + sk.asHexString.toString() + "' and will be " +
"signing the message '" + msg + "'.")
)
if (!lazySodium.cryptoSignKeypair(pk.asBytes, sk.asBytes)) {
throw SodiumException("Could not generate a signing keypair.")
}
val signed: String = lazySodium.cryptoSignDetached(msg, sk)
val verification: Boolean = lazySodium.cryptoSignVerifyDetached(signed, msg, pk)
log()
logt("The signed message is $signed.")