Java Key Public getPublicKey(final byte[] modulus, final byte[] exponent)

Here you can find the source of getPublicKey(final byte[] modulus, final byte[] exponent)

Description

get Public Key

License

LGPL

Declaration

public static RSAPublicKey getPublicKey(final byte[] modulus, final byte[] exponent) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.math.BigInteger;
import java.security.*;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.RSAPublicKeySpec;

public class Main {
    public static final String EBICS_ENCRYPTION_KEY_ALGORITHM = "RSA";

    public static RSAPublicKey getPublicKey(final byte[] modulus, final byte[] exponent) {
        final RSAPublicKeySpec spec = new RSAPublicKeySpec(new BigInteger(modulus), new BigInteger(exponent));
        try {/*from   w ww .  java 2 s.co m*/
            final KeyFactory factory = KeyFactory.getInstance(EBICS_ENCRYPTION_KEY_ALGORITHM);
            return (RSAPublicKey) factory.generatePublic(spec);
        } catch (final GeneralSecurityException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getPublicKey()
  2. getPublicKey(BigInteger modulus, BigInteger exponent)
  3. getPublicKey(byte[] der)
  4. getPublicKey(byte[] keyBytes, String algorithm)
  5. getPublicKey(final byte[] keyData)
  6. getPublicKey(final String algorithm, final File publicKeyFile)
  7. getPublicKey(KeyPair keyPair)
  8. getPublicKey(KeyPair keyPair)
  9. getPublicKey(KeyPair kp)