Package com.goterl.lazysodium.interfaces
Interface Box.Lazy
-
- All Known Implementing Classes:
LazySodium,LazySodiumJava
- Enclosing interface:
- Box
public static interface Box.Lazy
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringcryptoBoxBeforeNm(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.java.lang.StringcryptoBoxBeforeNm(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.DetachedEncryptcryptoBoxDetachedAfterNm(java.lang.String message, byte[] nonce, java.lang.String sharedSecretKey)Encrypt a message but allow for storage of the mac separately.java.lang.StringcryptoBoxEasy(java.lang.String message, byte[] nonce, KeyPair keyPair)Encrypts a message.java.lang.StringcryptoBoxEasyAfterNm(java.lang.String message, byte[] nonce, java.lang.String sharedSecretKey)Encrypt a message.KeyPaircryptoBoxKeypair()Generate a secret and public key.DetachedDecryptcryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, byte[] nonce, java.lang.String sharedSecretKey)Decrypt a message.java.lang.StringcryptoBoxOpenEasy(java.lang.String cipherText, byte[] nonce, KeyPair keyPair)Decrypts a previously encrypted message.java.lang.StringcryptoBoxOpenEasyAfterNm(java.lang.String cipher, byte[] nonce, java.lang.String sharedSecretKey)Decrypt a message.java.lang.StringcryptoBoxSealEasy(java.lang.String message, Key publicKey)Encrypts a message.java.lang.StringcryptoBoxSealOpenEasy(java.lang.String cipherText, KeyPair keyPair)Decrypts a previously encrypted message.KeyPaircryptoBoxSeedKeypair(byte[] seed)Generate a public and secret key deterministically.
-
-
-
Method Detail
-
cryptoBoxKeypair
KeyPair cryptoBoxKeypair() throws SodiumException
Generate a secret and public key.- Returns:
- Secret and public key.
- Throws:
SodiumException
-
cryptoBoxSeedKeypair
KeyPair cryptoBoxSeedKeypair(byte[] seed) throws SodiumException
Generate a public and secret key deterministically.- Parameters:
seed- The seed to generate the key.- Returns:
- Public and secret key.
- Throws:
SodiumException
-
cryptoBoxEasy
java.lang.String cryptoBoxEasy(java.lang.String message, byte[] nonce, KeyPair keyPair) throws SodiumExceptionEncrypts 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
java.lang.String cryptoBoxOpenEasy(java.lang.String cipherText, byte[] nonce, KeyPair keyPair) throws SodiumExceptionDecrypts 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
java.lang.String cryptoBoxBeforeNm(byte[] publicKey, byte[] secretKey) throws SodiumExceptionIf 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
java.lang.String cryptoBoxBeforeNm(KeyPair keyPair) throws SodiumException
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
java.lang.String cryptoBoxEasyAfterNm(java.lang.String message, byte[] nonce, java.lang.String sharedSecretKey) throws SodiumExceptionEncrypt 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
java.lang.String cryptoBoxOpenEasyAfterNm(java.lang.String cipher, byte[] nonce, java.lang.String sharedSecretKey) throws SodiumExceptionDecrypt 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(java.lang.String message, byte[] nonce, java.lang.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, java.lang.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
java.lang.String cryptoBoxSealEasy(java.lang.String message, Key publicKey) throws SodiumExceptionEncrypts a message.- Parameters:
message- The message.publicKey- A public key.- Returns:
- The encrypted
Helpers.Lazy.sodiumBin2Hex(byte[])'ified cipher text. - Throws:
SodiumException
-
cryptoBoxSealOpenEasy
java.lang.String cryptoBoxSealOpenEasy(java.lang.String cipherText, KeyPair keyPair) throws SodiumExceptionDecrypts a previously encrypted message.- Parameters:
cipherText- Encrypted viacryptoBoxSealEasy(String, Key)and thenHelpers.Lazy.sodiumBin2Hex(byte[])'ified.keyPair- A keypair.- Returns:
- The message.
- Throws:
SodiumException
-
-