public class NaCl extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BEFORENMBYTES |
static int |
BOXOVERHEAD |
static int |
BOXZEROBYTES |
static int |
NONCEBYTES |
static int |
PUBLICKEYBYTES |
static int |
SECRETKEYBYTES |
static int |
STREAMKEYBYTES |
static int |
SYMMKEYBYTES |
static int |
ZEROBYTES |
Constructor and Description |
---|
NaCl(byte[] privatekey,
byte[] publickey) |
NaCl(String privatekey,
String publickey) |
Modifier and Type | Method and Description |
---|---|
static String |
asHex(byte[] buf) |
static String |
asHex(int[] buf) |
byte[] |
decrypt(byte[] input,
byte[] nonce) |
byte[] |
decrypt(byte[] input,
int inputlength,
byte[] nonce) |
static byte[] |
derivePublicKey(byte[] privatekey) |
byte[] |
encrypt(byte[] input,
byte[] nonce) |
byte[] |
encrypt(byte[] input,
int inputlength,
byte[] nonce) |
static void |
genkeypair(byte[] publickey,
byte[] privatekey) |
static void |
genkeypair(byte[] publickey,
byte[] privatekey,
byte[] seed) |
static byte[] |
getBinary(String s) |
static void |
selfTest() |
static byte[] |
streamCryptData(byte[] input,
byte[] key,
byte[] nonce) |
static byte[] |
symmetricDecryptData(byte[] input,
byte[] key,
byte[] nonce) |
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. |
static byte[] |
symmetricEncryptData(byte[] input,
byte[] key,
byte[] nonce) |
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. |
public static final int PUBLICKEYBYTES
public static final int SECRETKEYBYTES
public static final int BEFORENMBYTES
public static final int NONCEBYTES
public static final int ZEROBYTES
public static final int BOXZEROBYTES
public static final int BOXOVERHEAD
public static final int SYMMKEYBYTES
public static final int STREAMKEYBYTES
public byte[] encrypt(byte[] input, byte[] nonce)
public byte[] encrypt(byte[] input, int inputlength, byte[] nonce)
public byte[] decrypt(byte[] input, byte[] nonce)
public byte[] decrypt(byte[] input, int inputlength, byte[] nonce)
public static void genkeypair(byte[] publickey, byte[] privatekey)
public static void genkeypair(byte[] publickey, byte[] privatekey, byte[] seed)
public static byte[] derivePublicKey(byte[] privatekey)
public static byte[] symmetricEncryptData(byte[] input, byte[] key, byte[] nonce)
public static void symmetricEncryptDataInplace(byte[] io, byte[] key, byte[] nonce)
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).io
- plaintext on input (starting at offset BOXOVERHEAD), ciphertext on return (full array)key
- encryption keynonce
- encryption noncepublic static byte[] symmetricDecryptData(byte[] input, byte[] key, byte[] nonce)
public static boolean symmetricDecryptDataInplace(byte[] io, byte[] key, byte[] nonce)
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.io
- ciphertext on input (full array), plaintext on output (last BOXOVERHEAD bytes set to zero)key
- encryption keynonce
- encryption noncepublic static byte[] streamCryptData(byte[] input, byte[] key, byte[] nonce)
public static byte[] getBinary(String s)
public static String asHex(byte[] buf)
public static String asHex(int[] buf)
public static void selfTest()
Copyright © 2015 Threema GmbH, Staldenbachstrasse 11, 8808 Pfäffikon SZ, Schweiz. All rights reserved.