Class XTEA

  • All Implemented Interfaces:
    BlockCipher

    public class XTEA
    extends java.lang.Object
    implements BlockCipher
    An implementation of the XTEA block cipher algorithm.

    This implementation uses 32 rounds. The best attack reported as of 2009 is 36 rounds (Wikipedia).

    • Constructor Summary

      Constructors 
      Constructor Description
      XTEA()  
    • Method Summary

      All Methods Instance Methods Concrete 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[] b)
      Set the encryption key used for encrypting and decrypting.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XTEA

        public XTEA()
    • Method Detail

      • setKey

        public void setKey​(byte[] b)
        Description copied from interface: BlockCipher
        Set the encryption key used for encrypting and decrypting. The key needs to be 16 bytes long.
        Specified by:
        setKey in interface BlockCipher
        Parameters:
        b - the key
      • encrypt

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

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

        public int getKeyLength()
        Description copied from interface: BlockCipher
        Get the length of the key in bytes.
        Specified by:
        getKeyLength in interface BlockCipher
        Returns:
        the length of the key