Interface Box.Lazy
- All Known Implementing Classes:
LazySodium,LazySodiumJava
- Enclosing interface:
- Box
public static interface Box.Lazy
-
Method Summary
Modifier and TypeMethodDescriptioncryptoBoxBeforeNm(byte[] publicKey, byte[] secretKey) If you send several messages to the same receiver or receive several messages from the same sender, you can gain speed by calculating the shared key only once, and reusing it in subsequent operations.cryptoBoxBeforeNm(KeyPair keyPair) If you send several messages to the same receiver or receive several messages from the same sender, you can gain speed by calculating the shared key only once, and reusing it in subsequent operations.cryptoBoxDetachedAfterNm(String message, byte[] nonce, String sharedSecretKey) Encrypt a message but allow for storage of the mac separately.cryptoBoxEasy(String message, byte[] nonce, KeyPair keyPair) Encrypts a message.cryptoBoxEasyAfterNm(String message, byte[] nonce, String sharedSecretKey) Encrypt a message.Generate a secret and public key.cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, byte[] nonce, String sharedSecretKey) Decrypt a message.cryptoBoxOpenEasy(String cipherText, byte[] nonce, KeyPair keyPair) Decrypts a previously encrypted message.cryptoBoxOpenEasyAfterNm(String cipher, byte[] nonce, String sharedSecretKey) Decrypt a message.cryptoBoxSealEasy(String message, Key publicKey) Encrypts a message.cryptoBoxSealOpenEasy(String cipherText, KeyPair keyPair) Decrypts a previously encrypted message.cryptoBoxSeedKeypair(byte[] seed) Generate a public and secret key deterministically.
-
Method Details
-
cryptoBoxKeypair
Generate a secret and public key.- Returns:
- Secret and public key.
- Throws:
SodiumException
-
cryptoBoxSeedKeypair
Generate a public and secret key deterministically.- Parameters:
seed- The seed to generate the key.- Returns:
- Public and secret key.
- Throws:
SodiumException
-
cryptoBoxEasy
Encrypts a message.- Parameters:
message- The message.nonce- The nonce of sizeBox.NONCEBYTES.keyPair- A keypair.- Returns:
- The encrypted
Helpers.Lazy.sodiumBin2Hex(byte[])'ified cipher text. - Throws:
SodiumException
-
cryptoBoxOpenEasy
Decrypts a previously encrypted message.- Parameters:
cipherText- Encrypted viacryptoBoxEasy(String, byte[], KeyPair)and thenHelpers.Lazy.sodiumBin2Hex(byte[])'ified.nonce- The nonce of sizeBox.NONCEBYTES.keyPair- A keypair.- Returns:
- The message.
- Throws:
SodiumException
-
cryptoBoxBeforeNm
If you send several messages to the same receiver or receive several messages from the same sender, you can gain speed by calculating the shared key only once, and reusing it in subsequent operations.- Parameters:
publicKey- A public key as generated bycryptoBoxKeypair().secretKey- A secret key as generated bycryptoBoxKeypair().- Returns:
- The shared secret key.
- Throws:
SodiumException- Incorrect key lengths.
-
cryptoBoxBeforeNm
If you send several messages to the same receiver or receive several messages from the same sender, you can gain speed by calculating the shared key only once, and reusing it in subsequent operations.- Parameters:
keyPair- A public and secret key as generated bycryptoBoxKeypair().- Returns:
- The shared secret key.
- Throws:
SodiumException- Incorrect key lengths.
-
cryptoBoxEasyAfterNm
String cryptoBoxEasyAfterNm(String message, byte[] nonce, String sharedSecretKey) throws SodiumException Encrypt a message.- Parameters:
message- The message for encryption.nonce- A randomly generated nonce viaRandom.nonce(int)}.sharedSecretKey- The shared secret key as generated viacryptoBoxBeforeNm(KeyPair).- Returns:
- The encrypted message.
- Throws:
SodiumException- Incorrect key lengths or enc error.
-
cryptoBoxOpenEasyAfterNm
String cryptoBoxOpenEasyAfterNm(String cipher, byte[] nonce, String sharedSecretKey) throws SodiumException Decrypt a message.- Parameters:
cipher- The cipher text to be decrypted.nonce- The same nonce used to encrypt thecipher-cryptoBoxEasyAfterNm(String, byte[], String).sharedSecretKey- The shared secret key as generated viacryptoBoxBeforeNm(KeyPair).- Returns:
- The decrypted message.
- Throws:
SodiumException- Incorrect key lengths or decryption error.
-
cryptoBoxDetachedAfterNm
DetachedEncrypt cryptoBoxDetachedAfterNm(String message, byte[] nonce, String sharedSecretKey) throws SodiumException Encrypt a message but allow for storage of the mac separately.- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce viaRandom.nonce(int)}.sharedSecretKey- The shared secret key as generated viacryptoBoxBeforeNm(KeyPair).- Returns:
- The encrypted message.
- Throws:
SodiumException- Incorrect key lengths or enc error.
-
cryptoBoxOpenDetachedAfterNm
DetachedDecrypt cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, byte[] nonce, String sharedSecretKey) throws SodiumException Decrypt a message.- Parameters:
detachedEncrypt- The cipher and mac used to decrypted the message.nonce- The same nonce used to encrypt -cryptoBoxDetachedAfterNm(String, byte[], String)}.sharedSecretKey- The shared secret key as generated viacryptoBoxBeforeNm(KeyPair).- Returns:
- The decrypted message with the
mac. - Throws:
SodiumException- Incorrect key lengths or decryption error.
-
cryptoBoxSealEasy
Encrypts a message.- Parameters:
message- The message.publicKey- A public key.- Returns:
- The encrypted
Helpers.Lazy.sodiumBin2Hex(byte[])'ified cipher text. - Throws:
SodiumException
-
cryptoBoxSealOpenEasy
Decrypts a previously encrypted message.- Parameters:
cipherText- Encrypted viacryptoBoxSealEasy(String, Key)and thenHelpers.Lazy.sodiumBin2Hex(byte[])'ified.keyPair- A keypair.- Returns:
- The message.
- Throws:
SodiumException
-