Example usage for javax.crypto IllegalBlockSizeException printStackTrace

List of usage examples for javax.crypto IllegalBlockSizeException printStackTrace

Introduction

In this page you can find the example usage for javax.crypto IllegalBlockSizeException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:poisondog.security.EncryptMission.java

@Override
public String execute(String input) throws NoSuchAlgorithmException, InvalidKeyException {
    SecretKeySpec skeySpec = new SecretKeySpec(mKey.getBytes(), mAlgorithm);
    try {/*w w w .  j  a  va  2s. co m*/
        Cipher cipher = Cipher.getInstance(mAlgorithm);
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
        byte[] encrypted = cipher.doFinal(input.getBytes());
        return Base64.encodeBase64String(encrypted);
    } catch (IllegalBlockSizeException e) {
        e.printStackTrace();
    } catch (NoSuchPaddingException e) {
        e.printStackTrace();
    } catch (BadPaddingException e) {
        e.printStackTrace();
    }
    return null;
}