core

## Class Crypter

- java.lang.Object
- - core.Crypter

-     public class Crypter
      extends java.lang.Object

  Encrypts and decrypts byte arrays, using encryption techniques found in Wireless M-bus.
  Author:
    David Hudec (dwdization@gmail.com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static byte[]` | `ZEROS_08`
    `static byte[]` | `ZEROS_16`
    `static byte[]` | `ZEROS_32`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Crypter()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private static byte[]` | `aes(int mode, byte[] key, byte[] IV, byte[] message)`
    `static byte[]` | `decrypt(EncryptionMethod method, byte[] key, byte[] message)` Decrypts given message by given encryption method with given key.
    `static byte[]` | `decrypt(EncryptionMethod method, byte[] key, byte[] IV, byte[] message)` Decrypts given message by given encryption method, with given key, using given initialization vector (can be null).
    `private static byte[]` | `des(int mode, byte[] key, byte[] IV, byte[] message)`
    `static byte[]` | `encrypt(EncryptionMethod method, byte[] key, byte[] message)` Encrypts given message by given encryption method with given key.
    `static byte[]` | `encrypt(EncryptionMethod method, byte[] key, byte[] IV, byte[] message)` Encrypts given message by given encryption method, with given key, using given initialization vector (can be null).

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

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

- - ### Field Detail

    - #### ZEROS_08

          public static final byte[] ZEROS_08

    - #### ZEROS_16

          public static final byte[] ZEROS_16

    - #### ZEROS_32

          public static final byte[] ZEROS_32

  - ### Constructor Detail

    - #### Crypter

          public Crypter()

  - ### Method Detail

    - #### aes

          private static byte[] aes(int mode,
                                    byte[] key,
                                    byte[] IV,
                                    byte[] message)
                             throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### decrypt

          public static byte[] decrypt(EncryptionMethod method,
                                       byte[] key,
                                       byte[] message)
                                throws java.lang.Exception

      Decrypts given message by given encryption method with given key.
      Parameters:
        `method` - decryption method to use
        `key` - decryption key to use
        `message` - message to decrypt
      Returns:
        decrypted message
      Throws:
        `java.lang.Exception` - if any error occurs

    - #### decrypt

          public static byte[] decrypt(EncryptionMethod method,
                                       byte[] key,
                                       byte[] IV,
                                       byte[] message)
                                throws java.lang.Exception

      Decrypts given message by given encryption method, with given key, using given initialization vector (can be null).
      Parameters:
        `method` - decryption method to use
        `key` - decryption key to use
        `IV` - initialization vector to use
        `message` - message to decrypt
      Returns:
        decrypted message
      Throws:
        `java.lang.Exception` - if any error occurs

    - #### des

          private static byte[] des(int mode,
                                    byte[] key,
                                    byte[] IV,
                                    byte[] message)
                             throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### encrypt

          public static byte[] encrypt(EncryptionMethod method,
                                       byte[] key,
                                       byte[] message)
                                throws java.lang.Exception

      Encrypts given message by given encryption method with given key.
      Parameters:
        `method` - encryption method to use
        `key` - encryption key to use
        `message` - message to encrypt
      Returns:
        encrypted message
      Throws:
        `java.lang.Exception` - if any error occurs

    - #### encrypt

          public static byte[] encrypt(EncryptionMethod method,
                                       byte[] key,
                                       byte[] IV,
                                       byte[] message)
                                throws java.lang.Exception

      Encrypts given message by given encryption method, with given key, using given initialization vector (can be null).
      Parameters:
        `method` - encryption method to use
        `key` - encryption key to use
        `IV` - initialization vector to use
        `message` - message to encrypt
      Returns:
        encrypted message
      Throws:
        `java.lang.Exception` - if any error occurs