Example usage for javax.crypto Cipher getInstance

List of usage examples for javax.crypto Cipher getInstance

Introduction

In this page you can find the example usage for javax.crypto Cipher getInstance.

Prototype

public static final Cipher getInstance(String transformation, Provider provider)
        throws NoSuchAlgorithmException, NoSuchPaddingException 

Source Link

Document

Returns a Cipher object that implements the specified transformation.

Usage

From source file:gov.nih.nci.security.util.AESEncryption.java

public AESEncryption(String passphrase, boolean isMD5Hash) throws EncryptionException {
    try {/*from www  . ja  v a 2 s .c  o  m*/
        this.provider = new BouncyCastleProvider();
        SecretKeySpec skey = getSKeySpec(passphrase, isMD5Hash);
        encryptCipher = Cipher.getInstance(AES_ENCRYPTION_SCHEME, provider);
        decryptCipher = Cipher.getInstance(AES_ENCRYPTION_SCHEME, provider);
        encryptCipher.init(Cipher.ENCRYPT_MODE, skey);
        AlgorithmParameters ap = encryptCipher.getParameters();
        decryptCipher.init(Cipher.DECRYPT_MODE, skey, ap);
    } catch (NoSuchAlgorithmException e) {
        throw new EncryptionException(e);
    } catch (NoSuchPaddingException e) {
        throw new EncryptionException(e);
    } catch (InvalidKeyException e) {
        throw new EncryptionException(e);
    } catch (InvalidAlgorithmParameterException e) {
        throw new EncryptionException(e);
    }
}