|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.logi.crypto.Crypto | +--org.logi.crypto.modes.EncryptMode | +--org.logi.crypto.modes.EncryptECB
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.
DecryptECB
Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
Constructor Summary | |
EncryptECB()
Create a new ECB-mode encrypt session with no key. |
|
EncryptECB(CipherKey key)
Create a new ECB-mode encrypt session with the specified key. |
Method Summary | |
void |
close()
Close files and kill threads owned by the object. |
byte[] |
encrypt(byte[] source,
int i,
int length)
Send bytes to the EncryptECB object for encryption. |
void |
finalize()
|
byte[] |
flush()
Pads the internal buffer, encrypts it and returns the ciphertext. |
byte[] |
flush(byte[] source,
int i,
int length)
Equivalent to calling encrypt(source,i,length)
followed by flush() . |
CipherKey |
getKey()
Return the key used for encryption. |
int |
plainBlockSize()
Return the size of the blocks of plaintext encrypted by this object. |
void |
setKey(CipherKey key)
Set the key to use for encryption. |
Methods inherited from class org.logi.crypto.Crypto |
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EncryptECB(CipherKey key)
public EncryptECB()
setKey()
method has been called.Method Detail |
public CipherKey getKey()
public void setKey(CipherKey key) throws CryptoException
CryptoException
- if there is data in the internal buffer
which should be encrypted with the old key.public int plainBlockSize()
public byte[] flush()
public byte[] encrypt(byte[] source, int i, int length)
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
.
public byte[] flush(byte[] source, int i, int length)
encrypt(source,i,length)
followed by flush()
.flush
in interface EncryptSession
public void close()
EncryptSession
close
in interface EncryptSession
public void finalize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |