Have a look at the source code for the vvarious classes in is.logi.crypto.test.
This happend when you use the ECB or CBC modes, which need a whole multiple of blocks to pass to the encryption key. The size of the block depends on the key used and is returned by the CipherKey.plainBlockSize() method.
If less than a whole multiple of blocks has been sent to the EncryptECB or EncryptCBC object when flush() is called, random data will be appended to make certain attacks on the key more difficult.
Some possible solutions include sending the size of the message along with the message itself or making certain that the message size is a whole multiple of blocks. Alternatively, you may want to use either the CFB of OFB modes.
Normally, passwords are not ancrypted, but hashed. Hashing can be thought of as one-way eincryption. There is no key to get back the original password, even if you know the hashed password.
In logi.crypto, you could hash a password with code similar to this:
String password = getPassword(); Fingerprint fp = Fingerprint.create(password,"SHA1");Now you would check that
fp
is the same as what is stored
in the password list of the system.
In the above, "SHA1" is the name of the hash-function used. It can be replaced with "MD5" and possibly others will be added in the future.