Last active
June 25, 2016 01:59
-
-
Save rf-/eb31bc57b21b766c68ecbbdfc2322f8b to your computer and use it in GitHub Desktop.
Kalium issue repro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.11.8" | |
resolvers += "Sonatype" at "https://oss.sonatype.org/content/repositories/releases" | |
resolvers += "Twitter" at "https://maven.twttr.com/" | |
libraryDependencies ++= Seq( | |
"asm" % "asm" % "3.1", | |
"org.abstractj.kalium" % "kalium" % "0.4.0" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import java.security.SecureRandom | |
import org.abstractj.kalium.NaCl.Sodium.XSALSA20_POLY1305_SECRETBOX_NONCEBYTES | |
import org.abstractj.kalium.NaCl.Sodium.XSALSA20_POLY1305_SECRETBOX_KEYBYTES | |
import org.abstractj.kalium.crypto.SecretBox | |
object Main extends App { | |
val secureRandom = new SecureRandom | |
val nonce = { | |
val bytes = new Array[Byte](XSALSA20_POLY1305_SECRETBOX_NONCEBYTES) | |
secureRandom.nextBytes(bytes) | |
bytes | |
} | |
val key = { | |
val bytes = new Array[Byte](XSALSA20_POLY1305_SECRETBOX_KEYBYTES) | |
secureRandom.nextBytes(bytes) | |
bytes | |
} | |
val box = new SecretBox(key) | |
box.encrypt(nonce, "Hello world!".getBytes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: