public static interface SecretBox.Native
| Modifier and Type | Method and Description |
|---|---|
boolean |
cryptoSecretBoxDetached(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
Encrypts a message.
|
boolean |
cryptoSecretBoxEasy(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
Encrypts a message using a key generated by
cryptoSecretBoxKeygen(byte[]). |
void |
cryptoSecretBoxKeygen(byte[] key)
Creates a random key.
|
boolean |
cryptoSecretBoxOpenDetached(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] key)
Decrypts a message with the mac and the cipher provided
separately.
|
boolean |
cryptoSecretBoxOpenEasy(byte[] message,
byte[] cipherText,
long cipherTextLen,
byte[] nonce,
byte[] key)
Decrypts and verifies a message using a key generated
by
cryptoSecretBoxKeygen(byte[]). |
void cryptoSecretBoxKeygen(byte[] key)
Random.randomBytesBuf(int) but improves code
clarity and can prevent misuse by ensuring
that the provided key length is
always correct.key - The key which is of size SecretBox.KEYBYTES.boolean cryptoSecretBoxEasy(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cryptoSecretBoxKeygen(byte[]).cipherText - The cipher text. Should be at least SecretBox.MACBYTES + messageLen.message - The message to encrypt.messageLen - The message byte array length.nonce - A nonce of size SecretBox.NONCEBYTES generated by Random.randomBytesBuf(int).key - The symmetric key generated by cryptoSecretBoxKeygen(byte[]).boolean cryptoSecretBoxOpenEasy(byte[] message,
byte[] cipherText,
long cipherTextLen,
byte[] nonce,
byte[] key)
cryptoSecretBoxKeygen(byte[]).message - The message will be put into here once decrypted.cipherText - The cipher produced by cryptoSecretBoxEasy(byte[], byte[], long, byte[], byte[]).cipherTextLen - The cipher text length.nonce - This has to be the same nonce that was used when
encrypting using cryptoSecretBoxEasy.key - The key generated by cryptoSecretBoxKeygen(byte[]).boolean cryptoSecretBoxDetached(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cipherText - The encrypted message of length messageLen.mac - The mac.message - The message to encrypt.messageLen - The message's length.nonce - A randomly generated nonce of size SecretBox.NONCEBYTES. Use Random.randomBytesBuf(int).key - The key generated by cryptoSecretBoxKeygen(byte[]).boolean cryptoSecretBoxOpenDetached(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] key)
message - The message length which is the same size as cipherTextLen.cipherText - The cipher.mac - The mac.cipherTextLen - The cipher text length.nonce - The nonce that was used in cryptoSecretBoxDetached(byte[], byte[], byte[], long, byte[], byte[]).key - The key generated by cryptoSecretBoxKeygen(byte[]).