Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

dcrypt.crypto.ciphers.TEA


Syntax

class TEA : BlockCipher

Remarks

Implementation of the TEA cipher designed by David Wheeler and Roger Needham.

Inherits from

dcrypt.crypto.BlockCipher

Conforms to

None

Publically imports

None

References

Wikipedia TEA page

Members

Fields

ENCRYPT

Syntax
public static const bool ENCRYPT
Remarks

Constant whose value is true. Intended to be passed to the init method of ciphers. (Inherited from Cipher.)


DECRYPT

Syntax
public static const bool DECRYPT
Remarks

Constant whose value is false. Intended to be passed to the init method of ciphers. (Inherited from Cipher.)


Properties

name

Syntax
public char[] name()
Remarks

The name of the cipher. (Inherited from Cipher.)


initialized

Syntax
public bool initialized()
Remarks

Whether or not the cipher has been initialized. (Inherited from Cipher.)


blockSize

Syntax
public uint blockSize()
Remarks

The block size in bytes of this block cipher. (Inherited from BlockCipher.)


Methods

init

Syntax
public void init(bool encrypt, CipherParameters params)
Remarks

Initialize a cipher. (Inherited from Cipher.)


reset

Syntax
public void reset()
Remarks

Reset a cipher. (Inherited from Cipher.)


update

Syntax
public uint update(void[] input_, void[] output_)
Remarks

Process a block of data from the input array and place it in the output array. Returns the amount of data processed in bytes. (Inherited from Cipher.)


Example

// dcrypt does NOT rely on Phobos or Tango
import tango.io.Console;
import dcrypt.misc.Util;

import dcrypt.crypto.params.SymmetricKey;
import dcrypt.crypto.ciphers.TEA;

void main() {
    TEA tea = new TEA;
	
    // Create a simple test vector
    ubyte[] testBytes = new ubyte[tea.blockSize];
    testBytes[] = 0x00;
    
    // Initialize the cipher and encrypt the test vector
    tea.init(TEA.ENCRYPT, new SymmetricKey(testBytes));
    tea.update(testBytes, testBytes);

    Cout(Util.ubytesToHex(testBytes));
}