Java Key Public getPublicKey(byte[] der)

Here you can find the source of getPublicKey(byte[] der)

Description

get Public Key

License

Open Source License

Declaration

private static PublicKey getPublicKey(byte[] der)
            throws NoSuchAlgorithmException, InvalidKeySpecException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.security.KeyFactory;

import java.security.NoSuchAlgorithmException;

import java.security.PublicKey;

import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;

import java.security.spec.X509EncodedKeySpec;

public class Main {
    private static PublicKey getPublicKey(byte[] der)
            throws NoSuchAlgorithmException, InvalidKeySpecException {

        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        // decode public key
        X509EncodedKeySpec pubSpec = new X509EncodedKeySpec(der);
        RSAPublicKey pubKey = (RSAPublicKey) keyFactory
                .generatePublic(pubSpec);

        return pubKey;
    }// w ww.j a  v a2 s  . co  m
}

Related

  1. getPublicDeclaredMethods(Class clz)
  2. getPublicEncoded(KeyPair kp)
  3. getPublicExponent(PublicKey pubk)
  4. getPublicKey()
  5. getPublicKey(BigInteger modulus, BigInteger exponent)
  6. getPublicKey(byte[] keyBytes, String algorithm)
  7. getPublicKey(final byte[] keyData)
  8. getPublicKey(final byte[] modulus, final byte[] exponent)
  9. getPublicKey(final String algorithm, final File publicKeyFile)