Interface SecretBox.Lazy
- All Known Implementing Classes:
LazySodium,LazySodiumJava
- Enclosing interface:
- SecretBox
public static interface SecretBox.Lazy
-
Method Summary
Modifier and TypeMethodDescriptioncryptoSecretBoxDetached(String message, byte[] nonce, Key key) Encrypts a message with the mac separatelycryptoSecretBoxEasy(String message, byte[] nonce, Key key) Encrypts a message.Generates a secret symmetric key.cryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, byte[] nonce, Key key) Decrypts a message.cryptoSecretBoxOpenEasy(String cipher, byte[] nonce, Key key) Decrypts a message.
-
Method Details
-
cryptoSecretBoxKeygen
Key cryptoSecretBoxKeygen()Generates a secret symmetric key.- Returns:
- A secret symmetric key which has been through
Helpers.Lazy.sodiumBin2Hex(byte[]).
-
cryptoSecretBoxEasy
Encrypts a message.- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce of sizeSecretBox.NONCEBYTES. UseRandom.randomBytesBuf(int).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The cipher byte array that's been
Helpers.Lazy.sodiumBin2Hex(byte[])'ified. - Throws:
SodiumException
-
cryptoSecretBoxOpenEasy
Decrypts a message.- Parameters:
cipher- The hexadecimal cipher text. SeeHelpers.Lazy.sodiumBin2Hex(byte[]).nonce- The nonce that was used when you encrypted withcryptoSecretBoxEasy(String, byte[], Key).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The decrypted message.
- Throws:
SodiumException
-
cryptoSecretBoxDetached
DetachedEncrypt cryptoSecretBoxDetached(String message, byte[] nonce, Key key) throws SodiumException Encrypts a message with the mac separately- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce of sizeSecretBox.NONCEBYTES. UseRandom.randomBytesBuf(int).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The cipher byte array that's been
Helpers.Lazy.sodiumBin2Hex(byte[])'ified. - Throws:
SodiumException
-
cryptoSecretBoxOpenDetached
String cryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, byte[] nonce, Key key) throws SodiumException Decrypts a message.- Parameters:
cipherAndMac- The hexadecimal cipher text. SeeHelpers.Lazy.sodiumBin2Hex(byte[]).nonce- The nonce that was used when you encrypted withcryptoSecretBoxEasy(String, byte[], Key).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The decrypted message.
- Throws:
SodiumException
-