public static byte[] des_cksum(byte[] ivec,byte[] msg,byte[] key) throws KrbCryptoException {
  Cipher cipher=null;
  byte[] result=new byte[8];
  try {
    cipher=Cipher.getInstance("DES/CBC/NoPadding");
  }
 catch (  Exception e) {
    KrbCryptoException ke=new KrbCryptoException("JCE provider may not be installed. " + e.getMessage());
    ke.initCause(e);
    throw ke;
  }
  IvParameterSpec params=new IvParameterSpec(ivec);
  SecretKeySpec skSpec=new SecretKeySpec(key,"DES");
  try {
    SecretKeyFactory skf=SecretKeyFactory.getInstance("DES");
    SecretKey sk=(SecretKey)skSpec;
    cipher.init(Cipher.ENCRYPT_MODE,sk,params);
    for (int i=0; i < msg.length / 8; i++) {
      result=cipher.doFinal(msg,i * 8,8);
      cipher.init(Cipher.ENCRYPT_MODE,sk,(new IvParameterSpec(result)));
    }
  }
 catch (  GeneralSecurityException e) {
    KrbCryptoException ke=new KrbCryptoException(e.getMessage());
    ke.initCause(e);
    throw ke;
  }
  return result;
}

public static byte [ ] des_cksum ( byte [ ] ivec , byte [ ] msg , byte [ ] key ) throws KrbCryptoException { Cipher cipher = null ; byte [ ] result = new byte [ 8 ] ; try { cipher = Cipher . getInstance ( "DES/CBC/NoPadding" ) ; } catch ( Exception e ) { KrbCryptoException ke = new KrbCryptoException ( "JCE provider may not be installed. " + e . getMessage ( ) ) ; ke . initCause ( e ) ; throw ke ; } IvParameterSpec params = new IvParameterSpec ( ivec ) ; SecretKeySpec skSpec = new SecretKeySpec ( key , "DES" ) ; try { SecretKeyFactory skf = SecretKeyFactory . getInstance ( "DES" ) ; SecretKey sk = ( SecretKey ) skSpec ; cipher . init ( Cipher . ENCRYPT_MODE , sk , params ) ; for ( int i = 0 ; i < msg . length / 8 ; i ++ ) { result = cipher . doFinal ( msg , i * 8 , 8 ) ; cipher . init ( Cipher . ENCRYPT_MODE , sk , ( new IvParameterSpec ( result ) ) ) ; } } catch ( GeneralSecurityException e ) { KrbCryptoException ke = new KrbCryptoException ( e . getMessage ( ) ) ; ke . initCause ( e ) ; throw ke ; } return result ; }
encrypts the message blocks using des cbc and output the final block of 8 - byte ciphertext .
