Class NaCl

java.lang.Object
com.neilalexander.jnacl.NaCl

public class NaCl extends Object
  • Field Details

  • Constructor Details

    • NaCl

      public NaCl(byte[] privatekey, byte[] publickey)
    • NaCl

      public NaCl(String privatekey, String publickey)
  • Method Details

    • encrypt

      public byte[] encrypt(byte[] input, byte[] nonce)
    • encrypt

      public byte[] encrypt(byte[] input, int inputlength, byte[] nonce)
    • decrypt

      public byte[] decrypt(byte[] input, byte[] nonce)
    • decrypt

      public byte[] decrypt(byte[] input, int inputlength, byte[] nonce)
    • genkeypair

      public static void genkeypair(byte[] publickey, byte[] privatekey)
    • genkeypair

      public static void genkeypair(byte[] publickey, byte[] privatekey, byte[] seed)
    • derivePublicKey

      public static byte[] derivePublicKey(byte[] privatekey)
    • symmetricEncryptData

      public static byte[] symmetricEncryptData(byte[] input, byte[] key, byte[] nonce)
    • symmetricEncryptDataInplace

      public static void symmetricEncryptDataInplace(byte[] io, byte[] key, byte[] nonce)
      In-place version of symmetricEncryptData(byte[], byte[], byte[]) that stores the output in the same byte array as the input. The input data must begin at offset BOXOVERHEAD in the array (the first BOXOVERHEAD bytes are ignored and will be overwritten with the message authentication code during encryption).
      Parameters:
      io - plaintext on input (starting at offset BOXOVERHEAD), ciphertext on return (full array)
      key - encryption key
      nonce - encryption nonce
    • symmetricDecryptData

      public static byte[] symmetricDecryptData(byte[] input, byte[] key, byte[] nonce)
    • symmetricDecryptDataInplace

      public static boolean symmetricDecryptDataInplace(byte[] io, byte[] key, byte[] nonce)
      In-place version of symmetricDecryptData(byte[], byte[], byte[]) that stores the output in the same byte array as the input. Note that the decrypted output is shorter than the input, so the last BOXOVERHEAD bytes should be ignored in the decrypted output.
      Parameters:
      io - ciphertext on input (full array), plaintext on output (last BOXOVERHEAD bytes set to zero)
      key - encryption key
      nonce - encryption nonce
      Returns:
      decryption successful true/false
    • streamCryptData

      public static byte[] streamCryptData(byte[] input, byte[] key, byte[] nonce)
    • getBinary

      public static byte[] getBinary(String s)
    • asHex

      public static String asHex(byte[] buf)
    • asHex

      public static String asHex(int[] buf)
    • selfTest

      public static void selfTest()