All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class is.logi.crypto.modes.EncryptECB

java.lang.Object
   |
   +----is.logi.crypto.Crypto
           |
           +----is.logi.crypto.modes.EncryptMode
                   |
                   +----is.logi.crypto.modes.EncryptECB

public class EncryptECB
extends EncryptMode
Electronic Codebook Mode simply encrypts each block of plaintext independently. It is not as secure as for example CBC mode.

Because ECB mode encrypts one block at a time, encryption is only performed when a full block of data has been sent to the object. This also means that when you call the flush() method, random data is appended to the block before encryption. This can be avoided in two ways: Either by flushing regularly and sending the size of the data packets to the reciever, or by using the CFB or OFB modes.

Author:
Logi Ragnarsson (logir@hi.is)
See Also:
DecryptECB

Constructor Index

 o EncryptECB()
Create a new ECB-mode encrypt session with no key.
 o EncryptECB(CipherKey)
Create a new ECB-mode encrypt session with the specified key.

Method Index

 o encrypt(byte[], int, int)
Send bytes to the EncryptECB object for encryption.
 o flush()
Padds the internal buffer, encrypts it and returns the ciphertext.
 o getKey()
Return the key used for encryption.
 o setKey(CipherKey)
Set the key to use for encryption.

Constructors

 o EncryptECB
 public EncryptECB(CipherKey key)
Create a new ECB-mode encrypt session with the specified key.

 o EncryptECB
 public EncryptECB()
Create a new ECB-mode encrypt session with no key. No encryption can be performed until the setKey() method has been called.

Methods

 o getKey
 public CipherKey getKey()
Return the key used for encryption.

Overrides:
getKey in class EncryptMode
 o setKey
 public void setKey(CipherKey key)
Set the key to use for encryption. Do not call this method when there may be data in the internal buffer.

Overrides:
setKey in class EncryptMode
 o flush
 public synchronized byte[] flush()
Padds the internal buffer, encrypts it and returns the ciphertext.

Overrides:
flush in class EncryptMode
 o encrypt
 public synchronized byte[] encrypt(byte source[],
                                    int i,
                                    int length)
Send bytes to the EncryptECB object for encryption.

Encrypt length bytes from source, starting at i and return the ciphertext. Data is encrypted in blocks, so only whole blocks of ciphertext are written to dest. Any remaining plaintext will be stored and prepended to source in the next call to encrypt.

Overrides:
encrypt in class EncryptMode

All Packages  Class Hierarchy  This Package  Previous  Next  Index