public byte[] encrypt(byte[] data,byte[] key,byte[] ivec,int usage) throws KrbCryptoException {
  if (key.length > 8)   throw new KrbCryptoException("Invalid DES Key!");
  int new_size=data.length + confounderSize() + checksumSize();
  byte[] new_data;
  byte pad;
  if (new_size % blockSize() == 0) {
    new_data=new byte[new_size + blockSize()];
    pad=(byte)8;
  }
 else {
    new_data=new byte[new_size + blockSize() - new_size % blockSize()];
    pad=(byte)(blockSize() - new_size % blockSize());
  }
  for (int i=new_size; i < new_data.length; i++) {
    new_data[i]=pad;
  }
  byte[] conf=Confounder.bytes(confounderSize());
  System.arraycopy(conf,0,new_data,0,confounderSize());
  System.arraycopy(data,0,new_data,startOfData(),data.length);
  byte[] cksum=calculateChecksum(new_data,new_data.length);
  System.arraycopy(cksum,0,new_data,startOfChecksum(),checksumSize());
  byte[] cipher=new byte[new_data.length];
  Des.cbc_encrypt(new_data,cipher,key,ivec,true);
  return cipher;
}

public byte [ ] encrypt ( byte [ ] data , byte [ ] key , byte [ ] ivec , int usage ) throws KrbCryptoException { if ( key . length > 8 ) throw new KrbCryptoException ( "Invalid DES Key!" ) ; int new_size = data . length + confounderSize ( ) + checksumSize ( ) ; byte [ ] new_data ; byte pad ; if ( new_size % blockSize ( ) == 0 ) { new_data = new byte [ new_size + blockSize ( ) ] ; pad = ( byte ) 8 ; } else { new_data = new byte [ new_size + blockSize ( ) - new_size % blockSize ( ) ] ; pad = ( byte ) ( blockSize ( ) - new_size % blockSize ( ) ) ; } for ( int i = new_size ; i < new_data . length ; i ++ ) { new_data [ i ] = pad ; } byte [ ] conf = Confounder . bytes ( confounderSize ( ) ) ; System . arraycopy ( conf , 0 , new_data , 0 , confounderSize ( ) ) ; System . arraycopy ( data , 0 , new_data , startOfData ( ) , data . length ) ; byte [ ] cksum = calculateChecksum ( new_data , new_data . length ) ; System . arraycopy ( cksum , 0 , new_data , startOfChecksum ( ) , checksumSize ( ) ) ; byte [ ] cipher = new byte [ new_data . length ] ; Des . cbc_encrypt ( new_data , cipher , key , ivec , true ) ; return cipher ; }
encrypts the data using des in cbc mode .
