Example usage for javax.crypto.spec RC2ParameterSpec RC2ParameterSpec

List of usage examples for javax.crypto.spec RC2ParameterSpec RC2ParameterSpec

Introduction

In this page you can find the example usage for javax.crypto.spec RC2ParameterSpec RC2ParameterSpec.

Prototype

public RC2ParameterSpec(int effectiveKeyBits, byte[] iv) 

Source Link

Document

Constructs a parameter set for RC2 from the given effective key size (in bits) and an 8-byte IV.

Usage

From source file:it.scoppelletti.programmerpower.security.spi.RC2ParameterSpecFactory.java

public AlgorithmParameterSpec newInstance(Properties props, String prefix) {
    int keySize;/*from   w ww .j a  v a 2 s.  c  om*/
    String name, value;
    byte[] iv;
    AlgorithmParameterSpec param;

    name = Strings.concat(prefix, RC2ParameterSpecFactory.PROP_KEYSIZE);
    value = props.getProperty(name);
    if (Strings.isNullOrEmpty(value)) {
        throw new ArgumentNullException(name);
    }

    keySize = Integer.parseInt(value);

    name = Strings.concat(prefix, RC2ParameterSpecFactory.PROP_IV);
    value = props.getProperty(name);
    if (Strings.isNullOrEmpty(value)) {
        iv = null;
    } else {
        try {
            iv = Hex.decodeHex(value.toCharArray());
        } catch (DecoderException ex) {
            throw SecurityUtils.toSecurityException(ex);
        }
    }

    if (iv != null) {
        param = new RC2ParameterSpec(keySize, iv);
    } else {
        param = new RC2ParameterSpec(keySize);
    }

    return param;
}