anonymous
2007-11-04 07:32:17 UTC
public class StreamCipher
{
private StringBuffer plainText;
private StringBuffer cipherText;
private KeyStore keyStore;
public int blockSize = 0;
// all characters that are not recognized will be replaced by this
public static final byte PADDING_CHAR = ' ';
/**
* Initialize the Stream Cipher with the key
* @param key
*/
public StreamCipher(KeyStore key)
{
this.keyStore = key;
this.blockSize = key.getBlockSize();
}
public void setPlainText(String plainText)
{
this.plainText = this.padString(plainText.toLowerCase());
this.cipherText = null;
}
public void setCipherText(String cipherText)
{
this.cipherText = new StringBuffer(cipherText.toLowerCase());
this.plainText = null;
}
public String getCipherText()
{
return new String(cipherText);
}
public String getPlainText()
{
return new String(plainText);
}
/**
* Adds the block level padding for the strings, so that the number of characters
* are multiples of block si