Java tutorial
//package com.java2s; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; public class Main { public static RSAPrivateKey getRSAPriKeyfromEncoded(byte[] encKey) throws NoSuchAlgorithmException, InvalidKeySpecException { PKCS8EncodedKeySpec pubKeySpec = new PKCS8EncodedKeySpec(encKey); KeyFactory kf = KeyFactory.getInstance("RSA"); return (RSAPrivateKey) kf.generatePrivate(pubKeySpec); } }