print Public Key Info - Java Security

Java examples for Security:Key

Description

print Public Key Info

Demo Code


//package com.java2s;

import java.security.PublicKey;

import java.security.interfaces.RSAPublicKey;

public class Main {

    public static void printPublicKeyInfo(PublicKey publicKey) {
        RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey;
        System.out.println("----------RSAPublicKey----------");
        System.out.println("Modulus.length="
                + rsaPublicKey.getModulus().bitLength());
        System.out.println("Modulus="
                + rsaPublicKey.getModulus().toString());
        System.out.println("PublicExponent.length="
                + rsaPublicKey.getPublicExponent().bitLength());
        System.out.println("PublicExponent="
                + rsaPublicKey.getPublicExponent().toString());
    }/*  w  ww  .  j  a  va2  s .  c  o m*/
}

Related Tutorials