public static void cbc_encrypt(byte[] input,byte[] output,byte[] key,byte[] ivec,boolean encrypt) throws KrbCryptoException {
  Cipher cipher=null;
  try {
    cipher=Cipher.getInstance("DES/CBC/NoPadding");
  }
 catch (  GeneralSecurityException 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;
    if (encrypt)     cipher.init(Cipher.ENCRYPT_MODE,sk,params);
 else     cipher.init(Cipher.DECRYPT_MODE,sk,params);
    byte[] result;
    result=cipher.doFinal(input);
    System.arraycopy(result,0,output,0,result.length);
  }
 catch (  GeneralSecurityException e) {
    KrbCryptoException ke=new KrbCryptoException(e.getMessage());
    ke.initCause(e);
    throw ke;
  }
}

public static void cbc_encrypt ( byte [ ] input , byte [ ] output , byte [ ] key , byte [ ] ivec , boolean encrypt ) throws KrbCryptoException { Cipher cipher = null ; try { cipher = Cipher . getInstance ( "DES/CBC/NoPadding" ) ; } catch ( GeneralSecurityException 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 ; if ( encrypt ) cipher . init ( Cipher . ENCRYPT_MODE , sk , params ) ; else cipher . init ( Cipher . DECRYPT_MODE , sk , params ) ; byte [ ] result ; result = cipher . doFinal ( input ) ; System . arraycopy ( result , 0 , output , 0 , result . length ) ; } catch ( GeneralSecurityException e ) { KrbCryptoException ke = new KrbCryptoException ( e . getMessage ( ) ) ; ke . initCause ( e ) ; throw ke ; } }
creates a des cipher in electronic codebook mode , with no padding .
