-
public interface Box.Lazy
-
-
Method Summary
Modifier and Type Method Description abstract KeyPaircryptoBoxKeypair()Generate a secret and public key. abstract KeyPaircryptoBoxSeedKeypair(Array<byte> seed)Generate a public and secret key deterministically. abstract StringcryptoBoxEasy(String message, Array<byte> nonce, KeyPair keyPair)Encrypts a message. abstract StringcryptoBoxOpenEasy(String cipherText, Array<byte> nonce, KeyPair keyPair)Decrypts a previously encrypted message. abstract StringcryptoBoxBeforeNm(Array<byte> publicKey, Array<byte> secretKey)If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations. abstract StringcryptoBoxBeforeNm(KeyPair keyPair)If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations. abstract StringcryptoBoxEasyAfterNm(String message, Array<byte> nonce, String sharedSecretKey)Encrypt a message. abstract StringcryptoBoxOpenEasyAfterNm(String cipher, Array<byte> nonce, String sharedSecretKey)Decrypt a message. abstract DetachedEncryptcryptoBoxDetachedAfterNm(String message, Array<byte> nonce, String sharedSecretKey)Encrypt a message but allow for storage ofthe mac separately. abstract DetachedDecryptcryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, Array<byte> nonce, String sharedSecretKey)Decrypt a message. abstract StringcryptoBoxSealEasy(String message, Key publicKey)Encrypts a message. abstract StringcryptoBoxSealOpenEasy(String cipherText, KeyPair keyPair)Decrypts a previously encrypted message. -
-
Method Detail
-
cryptoBoxKeypair
abstract KeyPair cryptoBoxKeypair()
Generate a secret and public key.
-
cryptoBoxSeedKeypair
abstract KeyPair cryptoBoxSeedKeypair(Array<byte> seed)
Generate a public and secret key deterministically.
- Parameters:
seed- The seed to generate the key.
-
cryptoBoxEasy
abstract String cryptoBoxEasy(String message, Array<byte> nonce, KeyPair keyPair)
Encrypts a message.
- Parameters:
message- The message.nonce- The nonce of size NONCEBYTES.keyPair- A keypair.
-
cryptoBoxOpenEasy
abstract String cryptoBoxOpenEasy(String cipherText, Array<byte> nonce, KeyPair keyPair)
Decrypts a previously encrypted message.
- Parameters:
cipherText- Encrypted via cryptoBoxEasy and then sodiumBin2Hex'ified.nonce- The nonce of size NONCEBYTES.keyPair- A keypair.
-
cryptoBoxBeforeNm
abstract String cryptoBoxBeforeNm(Array<byte> publicKey, Array<byte> secretKey)
If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations.
- Parameters:
publicKey- A public key as generated by cryptoBoxKeypair.secretKey- A secret key as generated by cryptoBoxKeypair.
-
cryptoBoxBeforeNm
abstract String cryptoBoxBeforeNm(KeyPair keyPair)
If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations.
- Parameters:
keyPair- A public and secret key as generated by cryptoBoxKeypair.
-
cryptoBoxEasyAfterNm
abstract String cryptoBoxEasyAfterNm(String message, Array<byte> nonce, String sharedSecretKey)
Encrypt a message.
- Parameters:
message- The message for encryption.nonce- A randomly generated nonce via nonce}.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxOpenEasyAfterNm
abstract String cryptoBoxOpenEasyAfterNm(String cipher, Array<byte> nonce, String sharedSecretKey)
Decrypt a message.
- Parameters:
cipher- The cipher text to be decrypted.nonce- The same nonce used to encrypt the{@code cipher}- cryptoBoxEasyAfterNm.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxDetachedAfterNm
abstract DetachedEncrypt cryptoBoxDetachedAfterNm(String message, Array<byte> nonce, String sharedSecretKey)
Encrypt a message but allow for storage ofthe mac separately.
- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce via nonce}.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxOpenDetachedAfterNm
abstract DetachedDecrypt cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, Array<byte> nonce, String sharedSecretKey)
Decrypt a message.
- Parameters:
detachedEncrypt- The cipher and mac used to decrypted the message.nonce- The same nonce used to encrypt - cryptoBoxDetachedAfterNm}.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxSealEasy
abstract String cryptoBoxSealEasy(String message, Key publicKey)
Encrypts a message.
- Parameters:
message- The message.publicKey- A public key.
-
cryptoBoxSealOpenEasy
abstract String cryptoBoxSealOpenEasy(String cipherText, KeyPair keyPair)
Decrypts a previously encrypted message.
- Parameters:
cipherText- Encrypted via cryptoBoxSealEasy and then sodiumBin2Hex'ified.keyPair- A keypair.
-
-
-
-