Interface BlockCipher

  • All Known Implementing Classes:
    AES, Fog, XTEA

    public interface BlockCipher
    A block cipher is a data encryption algorithm that operates on blocks.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALIGN
      Blocks sizes are always multiples of this number.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void decrypt​(byte[] bytes, int off, int len)
      Decrypt a number of bytes.
      void encrypt​(byte[] bytes, int off, int len)
      Encrypt a number of bytes.
      int getKeyLength()
      Get the length of the key in bytes.
      void setKey​(byte[] key)
      Set the encryption key used for encrypting and decrypting.
    • Field Detail

      • ALIGN

        static final int ALIGN
        Blocks sizes are always multiples of this number.
        See Also:
        Constant Field Values
    • Method Detail

      • setKey

        void setKey​(byte[] key)
        Set the encryption key used for encrypting and decrypting. The key needs to be 16 bytes long.
        Parameters:
        key - the key
      • encrypt

        void encrypt​(byte[] bytes,
                     int off,
                     int len)
        Encrypt a number of bytes. This is done in-place, that means the bytes are overwritten.
        Parameters:
        bytes - the byte array
        off - the start index
        len - the number of bytes to encrypt
      • decrypt

        void decrypt​(byte[] bytes,
                     int off,
                     int len)
        Decrypt a number of bytes. This is done in-place, that means the bytes are overwritten.
        Parameters:
        bytes - the byte array
        off - the start index
        len - the number of bytes to decrypt
      • getKeyLength

        int getKeyLength()
        Get the length of the key in bytes.
        Returns:
        the length of the key