PBES2Core(String kdfAlgo,String cipherAlgo,int keySize) throws NoSuchAlgorithmException, NoSuchPaddingException {
  this.cipherAlgo=cipherAlgo;
  keyLength=keySize * 8;
  pbeAlgo="PBEWith" + kdfAlgo + "And"+ cipherAlgo+ "_"+ keyLength;
  if (cipherAlgo.equals("AES")) {
    blkSize=AESConstants.AES_BLOCK_SIZE;
    cipher=new CipherCore(new AESCrypt(),blkSize);
switch (kdfAlgo) {
case "HmacSHA1":
      kdf=new PBKDF2Core.HmacSHA1();
    break;
case "HmacSHA224":
  kdf=new PBKDF2Core.HmacSHA224();
break;
case "HmacSHA256":
kdf=new PBKDF2Core.HmacSHA256();
break;
case "HmacSHA384":
kdf=new PBKDF2Core.HmacSHA384();
break;
case "HmacSHA512":
kdf=new PBKDF2Core.HmacSHA512();
break;
default :
throw new NoSuchAlgorithmException("No Cipher implementation for " + kdfAlgo);
}
}
 else {
throw new NoSuchAlgorithmException("No Cipher implementation for " + pbeAlgo);
}
cipher.setMode("CBC");
cipher.setPadding("PKCS5Padding");
}

PBES2Core ( String kdfAlgo , String cipherAlgo , int keySize ) throws NoSuchAlgorithmException , NoSuchPaddingException { this . cipherAlgo = cipherAlgo ; keyLength = keySize * 8 ; pbeAlgo = "PBEWith" + kdfAlgo + "And" + cipherAlgo + "_" + keyLength ; if ( cipherAlgo . equals ( "AES" ) ) { blkSize = AESConstants . AES_BLOCK_SIZE ; cipher = new CipherCore ( new AESCrypt ( ) , blkSize ) ; switch ( kdfAlgo ) { case "HmacSHA1" : kdf = new PBKDF2Core . HmacSHA1 ( ) ; break ; case "HmacSHA224" : kdf = new PBKDF2Core . HmacSHA224 ( ) ; break ; case "HmacSHA256" : kdf = new PBKDF2Core . HmacSHA256 ( ) ; break ; case "HmacSHA384" : kdf = new PBKDF2Core . HmacSHA384 ( ) ; break ; case "HmacSHA512" : kdf = new PBKDF2Core . HmacSHA512 ( ) ; break ; default : throw new NoSuchAlgorithmException ( "No Cipher implementation for " + kdfAlgo ) ; } } else { throw new NoSuchAlgorithmException ( "No Cipher implementation for " + pbeAlgo ) ; } cipher . setMode ( "CBC" ) ; cipher . setPadding ( "PKCS5Padding" ) ; }
creates an instance of pbe scheme 2 according to the selected password - based key derivation function and encryption scheme .
