create Key Factory by algorithm - Java Security

Java examples for Security:Key

Description

create Key Factory by algorithm

Demo Code


//package com.java2s;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static void main(String[] argv) throws Exception {
        String algorithm = "java2s.com";
        System.out.println(createKeyFactory(algorithm));
    }/*from  www .  j a  va  2 s.  c o  m*/

    public static KeyFactory createKeyFactory(String algorithm) {
        try {
            return KeyFactory.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("required " + algorithm
                    + " key factory not supported", e);
        }
    }
}

Related Tutorials