Package com.codahale.xsalsa20poly1305
Class SimpleBox
- java.lang.Object
-
- com.codahale.xsalsa20poly1305.SimpleBox
-
public class SimpleBox extends java.lang.ObjectConvenience functions for encryption without requiring nonce management.Compatible with RbNaCl's SimpleBox construction, but generates misuse-resistant nonces.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<byte[]>open(byte[] ciphertext)Decrypt the ciphertext with the given key.byte[]seal(byte[] plaintext)Encrypt the plaintext with the given key.
-
-
-
Constructor Detail
-
SimpleBox
public SimpleBox(byte[] secretKey)
Create a newSimpleBoxinstance with the given secret key.- Parameters:
secretKey- a 32-byte secret key
-
SimpleBox
public SimpleBox(byte[] publicKey, byte[] privateKey)Create a newSecretBoxinstance given a Curve25519 public key and a Curve25519 private key.- Parameters:
publicKey- a Curve25519 public keyprivateKey- a Curve25519 private key
-
-
Method Detail
-
seal
public byte[] seal(byte[] plaintext)
Encrypt the plaintext with the given key.- Parameters:
plaintext- any arbitrary bytes- Returns:
- the ciphertext
-
open
public java.util.Optional<byte[]> open(byte[] ciphertext)
Decrypt the ciphertext with the given key.- Parameters:
ciphertext- an encrypted message- Returns:
- an
Optionalof the original plaintext, or if either the key, nonce, or ciphertext was modified, an emptyOptional
-
-