net.i2p.crypto

## Class ChaCha20

- java.lang.Object
- - net.i2p.crypto.ChaCha20

-     public final class ChaCha20
      extends Object

  ChaCha20, wrapper around Noise ChaChaCore. RFC 7539

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `decrypt(byte[] key, byte[] iv, byte[] ciphertext, int ciphertextOffset, byte[] plaintext, int plaintextOffset, int length)` Encrypt from ciphertext to plaintext
    `static void` | `decrypt(byte[] key, byte[] iv, int ivOffset, byte[] ciphertext, int ciphertextOffset, byte[] plaintext, int plaintextOffset, int length)` Encrypt from ciphertext to plaintext
    `static void` | `encrypt(byte[] key, byte[] iv, byte[] plaintext, int plaintextOffset, byte[] ciphertext, int ciphertextOffset, int length)` Encrypt from plaintext to ciphertext
    `static void` | `encrypt(byte[] key, byte[] iv, int ivOffset, byte[] plaintext, int plaintextOffset, byte[] ciphertext, int ciphertextOffset, int length)` Encrypt from plaintext to ciphertext

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### decrypt

          public static void decrypt(byte[] key,
                                     byte[] iv,
                                     byte[] ciphertext,
                                     int ciphertextOffset,
                                     byte[] plaintext,
                                     int plaintextOffset,
                                     int length)

      Encrypt from ciphertext to plaintext
      Parameters:
        `key` - first 32 bytes used as the key
        `iv` - first 12 bytes used as the iv
        `ciphertext` - the ciphertext to decrypt
        `ciphertextOffset` - offset in ciphertext
        `plaintext` - the plaintext output buffer
        `plaintextOffset` - offset in plaintext
        `length` - the length to decrypt

    - #### decrypt

          public static void decrypt(byte[] key,
                                     byte[] iv,
                                     int ivOffset,
                                     byte[] ciphertext,
                                     int ciphertextOffset,
                                     byte[] plaintext,
                                     int plaintextOffset,
                                     int length)

      Encrypt from ciphertext to plaintext
      Parameters:
        `key` - first 32 bytes used as the key
        `iv` - first 12 bytes starting at ivOffset used as the iv
        `ciphertext` - the ciphertext to decrypt
        `ciphertextOffset` - offset in ciphertext
        `plaintext` - the plaintext output buffer
        `plaintextOffset` - offset in plaintext
        `length` - the length to decrypt

    - #### encrypt

          public static void encrypt(byte[] key,
                                     byte[] iv,
                                     byte[] plaintext,
                                     int plaintextOffset,
                                     byte[] ciphertext,
                                     int ciphertextOffset,
                                     int length)

      Encrypt from plaintext to ciphertext
      Parameters:
        `key` - first 32 bytes used as the key
        `iv` - first 12 bytes used as the iv
        `plaintext` - the plaintext to encrypt
        `plaintextOffset` - offset in plaintext
        `ciphertext` - the ciphertext output buffer
        `ciphertextOffset` - offset in ciphertext
        `length` - the length to encrypt

    - #### encrypt

          public static void encrypt(byte[] key,
                                     byte[] iv,
                                     int ivOffset,
                                     byte[] plaintext,
                                     int plaintextOffset,
                                     byte[] ciphertext,
                                     int ciphertextOffset,
                                     int length)

      Encrypt from plaintext to ciphertext
      Parameters:
        `key` - first 32 bytes used as the key
        `iv` - first 12 bytes starting at ivOffset used as the iv