From d4955dc7cd2be0095016c8040bf8466644cfb934 Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Mon, 22 Feb 2021 22:56:28 +0100 Subject: [PATCH] Make sample use box --- .../kotlin/com/ionspin/kotlin/crypto/sample/MainActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sample/src/androidMain/kotlin/com/ionspin/kotlin/crypto/sample/MainActivity.kt b/sample/src/androidMain/kotlin/com/ionspin/kotlin/crypto/sample/MainActivity.kt index 938802d..6b492f3 100644 --- a/sample/src/androidMain/kotlin/com/ionspin/kotlin/crypto/sample/MainActivity.kt +++ b/sample/src/androidMain/kotlin/com/ionspin/kotlin/crypto/sample/MainActivity.kt @@ -32,9 +32,11 @@ class MainActivity : AppCompatActivity() { val senderKeypair = Box.keypair() val recipientKeypair = Box.keypair() val messageNonce = Random(0).nextUBytes(crypto_box_NONCEBYTES) - val encrypted = Box.easy(message, messageNonce, recipientKeypair.publicKey, senderKeypair.secretKey) - val decrypted = Box.openEasy(encrypted, messageNonce, senderKeypair.publicKey, recipientKeypair.secretKey) val builder = StringBuilder() + val encrypted = Box.easy(message, messageNonce, recipientKeypair.publicKey, senderKeypair.secretKey) + builder.appendLine("Encrypted: ${encrypted.toHexString()}") + val decrypted = Box.openEasy(encrypted, messageNonce, senderKeypair.publicKey, recipientKeypair.secretKey) + builder.appendLine("Decrypted: ${decrypted.decodeFromUByteArray()}") try { val tampered = encrypted.copyOf()