www.pudn.com > encryption.rar > Cipher.java
/*
Christoforos Pirillos @ Villanova University - May 1999
based on code from the book "Java Network Programming" by Hughes
*/
package encryption;
/**This is a generic superclass of all ciphers; it declares the basic
methods to encipher and decipher data. The class is oriented towards
ciphers that encrypt data in blocks, and provides methods that encrypt
large amounts of data by making repeatead calls to the single block
encryption methods.
Actual implementations of this class must provide implementations of the
blockSize(), encipherBlock(), and decipherBlock() methods*/
public abstract class Cipher {
/**Encrypts len bytes of the array plain starting from index off, and
returns the encrypted result*/
public byte[] encipher (byte[] plain, int off, int len) {
int n = blockSize();
byte[] cipher = new byte[((len + n -1)/n) *n];
int i;
for (i=0; i