Package 

Interface SecretBox.Native

    • Method Detail

      • cryptoSecretBoxKeygen

         abstract void cryptoSecretBoxKeygen(Array<byte> key)

        Creates a random key. It is equivalent to calling randomBytesBuf but improves codeclarity and can prevent misuse by ensuringthat the provided key length isalways correct.

        Parameters:
        key - The key which is of size KEYBYTES.
      • cryptoSecretBoxOpenEasy

         abstract boolean cryptoSecretBoxOpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)

        Decrypts and verifies a message using a key generatedby cryptoSecretBoxKeygen.

        Parameters:
        message - The message will be put into here once decrypted.
        cipherText - The cipher produced by cryptoSecretBoxEasy.
        cipherTextLen - The cipher text length.
        nonce - This has to be the same nonce that was used whenencrypting using {@code cryptoSecretBoxEasy}.
        key - The key generated by cryptoSecretBoxKeygen.
      • cryptoSecretBoxDetached

         abstract boolean cryptoSecretBoxDetached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)

        Encrypts a message. Alongside the cipher a mac isreturned which can be stored in separate locations.

        Parameters:
        cipherText - The encrypted message of length {@code messageLen}.
        mac - The mac.
        message - The message to encrypt.
        messageLen - The message's length.
        nonce - A randomly generated nonce of size NONCEBYTES.
        key - The key generated by cryptoSecretBoxKeygen.
      • cryptoSecretBoxOpenDetached

         abstract boolean cryptoSecretBoxOpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)

        Decrypts a message with the mac and the cipher providedseparately.

        Parameters:
        message - The message length which is the same size as {@code cipherTextLen}.
        cipherText - The cipher.
        mac - The mac.
        cipherTextLen - The cipher text length.
        nonce - The nonce that was used in cryptoSecretBoxDetached.
        key - The key generated by cryptoSecretBoxKeygen.
      • cryptoSecretBoxXChaCha20Poly1305Keygen

         abstract void cryptoSecretBoxXChaCha20Poly1305Keygen(Array<byte> key)

        Creates a random key for the XChaCha20Poly1305 variant. It is equivalent to calling randomBytesBuf but improves codeclarity and can prevent misuse by ensuringthat the provided key length isalways correct.

        Parameters:
        key - The key which is of size XCHACHA20POLY1305_KEYBYTES.
      • cryptoSecretBoxXChaCha20Poly1305Detached

         abstract boolean cryptoSecretBoxXChaCha20Poly1305Detached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)

        Encrypts a message using the XChaCha20Poly1305 variant. Alongside the cipher a mac isreturned which can be stored in separate locations.

        Parameters:
        cipherText - The encrypted message of length {@code messageLen}.
        mac - The mac.
        message - The message to encrypt.
        messageLen - The message's length.
        nonce - A randomly generated nonce of size XCHACHA20POLY1305_NONCEBYTES.
        key - The key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.