Interface Box.Lazy

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String cryptoBoxBeforeNm​(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.String 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.
      DetachedEncrypt cryptoBoxDetachedAfterNm​(java.lang.String message, byte[] nonce, java.lang.String sharedSecretKey)
      Encrypt a message but allow for storage of the mac separately.
      java.lang.String cryptoBoxEasy​(java.lang.String message, byte[] nonce, KeyPair keyPair)
      Encrypts a message.
      java.lang.String cryptoBoxEasyAfterNm​(java.lang.String message, byte[] nonce, java.lang.String sharedSecretKey)
      Encrypt a message.
      KeyPair cryptoBoxKeypair()
      Generate a secret and public key.
      DetachedDecrypt cryptoBoxOpenDetachedAfterNm​(DetachedEncrypt detachedEncrypt, byte[] nonce, java.lang.String sharedSecretKey)
      Decrypt a message.
      java.lang.String cryptoBoxOpenEasy​(java.lang.String cipherText, byte[] nonce, KeyPair keyPair)
      Decrypts a previously encrypted message.
      java.lang.String cryptoBoxOpenEasyAfterNm​(java.lang.String cipher, byte[] nonce, java.lang.String sharedSecretKey)
      Decrypt a message.
      java.lang.String cryptoBoxSealEasy​(java.lang.String message, Key publicKey)
      Encrypts a message.
      java.lang.String cryptoBoxSealOpenEasy​(java.lang.String cipherText, KeyPair keyPair)
      Decrypts a previously encrypted message.
      KeyPair cryptoBoxSeedKeypair​(byte[] seed)
      Generate a public and secret key deterministically.
    • Method Detail

      • 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
      • cryptoBoxBeforeNm

        java.lang.String cryptoBoxBeforeNm​(byte[] publicKey,
                                           byte[] secretKey)
                                    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:
        publicKey - A public key as generated by cryptoBoxKeypair().
        secretKey - A secret key as generated by cryptoBoxKeypair().
        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 by cryptoBoxKeypair().
        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 SodiumException
        Encrypt a message.
        Parameters:
        message - The message for encryption.
        nonce - A randomly generated nonce via Random.nonce(int)}.
        sharedSecretKey - The shared secret key as generated via cryptoBoxBeforeNm(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 SodiumException
        Decrypt a message.
        Parameters:
        cipher - The cipher text to be decrypted.
        nonce - The same nonce used to encrypt the cipher - cryptoBoxEasyAfterNm(String, byte[], String).
        sharedSecretKey - The shared secret key as generated via cryptoBoxBeforeNm(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 via Random.nonce(int)}.
        sharedSecretKey - The shared secret key as generated via cryptoBoxBeforeNm(KeyPair).
        Returns:
        The encrypted message.
        Throws:
        SodiumException - Incorrect key lengths or enc error.