Example usage for java.security AlgorithmParameters getInstance

List of usage examples for java.security AlgorithmParameters getInstance

Introduction

In this page you can find the example usage for java.security AlgorithmParameters getInstance.

Prototype

public static AlgorithmParameters getInstance(String algorithm, Provider provider)
        throws NoSuchAlgorithmException 

Source Link

Document

Returns a parameter object for the specified algorithm.

Usage

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

    AlgorithmParameters params = AlgorithmParameters.getInstance("AES", "BC");
    IvParameterSpec ivSpec = new IvParameterSpec(new byte[16]);
    params.init(ivSpec);/*  w w  w .  j a  va2  s  . c  o  m*/
    ASN1InputStream aIn = new ASN1InputStream(params.getEncoded("ASN.1"));

    System.out.println(ASN1Dump.dumpAsString(aIn.readObject()));
}

From source file:org.alfresco.encryption.AbstractEncryptor.java

/**
 * {@inheritDoc}/*from  ww w  .  jav a 2s  . c  om*/
 */
@Override
public AlgorithmParameters decodeAlgorithmParameters(byte[] encoded) {
    try {
        AlgorithmParameters p = null;
        String algorithm = "DESede";
        if (getCipherProvider() != null) {
            p = AlgorithmParameters.getInstance(algorithm, getCipherProvider());
        } else {
            p = AlgorithmParameters.getInstance(algorithm);
        }
        p.init(encoded);
        return p;
    } catch (Exception e) {
        throw new AlfrescoRuntimeException("", e);
    }
}