print Private Key Info - Java Security

Java examples for Security:Key

Description

print Private Key Info

Demo Code


//package com.java2s;

import java.security.PrivateKey;

import java.security.interfaces.RSAPrivateKey;

public class Main {
    public static void printPrivateKeyInfo(PrivateKey privateKey) {
        RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) privateKey;
        System.out.println("----------RSAPrivateKey ----------");
        System.out.println("Modulus.length="
                + rsaPrivateKey.getModulus().bitLength());
        System.out.println("Modulus="
                + rsaPrivateKey.getModulus().toString());
        System.out.println("PrivateExponent.length="
                + rsaPrivateKey.getPrivateExponent().bitLength());
        System.out.println("PrivatecExponent="
                + rsaPrivateKey.getPrivateExponent().toString());

    }//from  w w w  .  j a v a  2 s . com
}

Related Tutorials