Package com.goterl.lazysodium.interfaces
Interface SecretBox.Lazy
-
- All Known Implementing Classes:
LazySodium,LazySodiumJava
- Enclosing interface:
- SecretBox
public static interface SecretBox.Lazy
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DetachedEncryptcryptoSecretBoxDetached(java.lang.String message, byte[] nonce, Key key)Encrypts a message with the mac separatelyjava.lang.StringcryptoSecretBoxEasy(java.lang.String message, byte[] nonce, Key key)Encrypts a message.KeycryptoSecretBoxKeygen()Generates a secret symmetric key.java.lang.StringcryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, byte[] nonce, Key key)Decrypts a message.java.lang.StringcryptoSecretBoxOpenEasy(java.lang.String cipher, byte[] nonce, Key key)Decrypts a message.
-
-
-
Method Detail
-
cryptoSecretBoxKeygen
Key cryptoSecretBoxKeygen()
Generates a secret symmetric key.- Returns:
- A secret symmetric key which has been through
Helpers.Lazy.sodiumBin2Hex(byte[]).
-
cryptoSecretBoxEasy
java.lang.String cryptoSecretBoxEasy(java.lang.String message, byte[] nonce, Key key) throws SodiumExceptionEncrypts 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
java.lang.String cryptoSecretBoxOpenEasy(java.lang.String cipher, byte[] nonce, Key key) throws SodiumExceptionDecrypts 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(java.lang.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
java.lang.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
-
-