INNER CODE UNIT · Kotlin

publicPrivateKeyEncryptionStep3

terl/lazysodium-java · sample-app/src/main/kotlin/Main.kt:168

    private fun publicPrivateKeyEncryptionStep3(encrypted: String, nonce: ByteArray, aliceKp: KeyPair, bobKp: KeyPair) {

        // Make sure we have Bob's private key decrypting the message with
        // Alice's public key.
        val bobFromAliceKp = KeyPair(aliceKp.getPublicKey(), bobKp.getSecretKey())
        val decrypted: String = lazySodium.cryptoBoxOpenEasy(encrypted, nonce, bobFromAliceKp)
        logt("Bob uses his private key to decrypt the message.")
        logt("Decryption result: '$decrypted'.")
        log()
    }

    @Throws(SodiumException::class)
    private fun genericHashStep1() {
        printSection("Running generic hash")

        // We can generate a random key or
        // we can provide a key.
        // String randomKey = lazySodium.cryptoGenericHashKeygen();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…