Hi Experts,
I am kind of confused with all these formats. In the following code, what format is the keys in?
If they are not DER formatted then how can I get base64-encoded DER format of private key and public key?
Any help is greatly appreciated... Thanks,
public void generateKeys( )
{
String retValue = null;
BASE64Encoder myB64 = new BASE64Encoder();
try
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(2048);
KeyPair keypair = keyGen.generateKeyPair();
Key privKey = keypair.getPrivate();
Key pubKey = keypair.getPublic();
m_PrivateKey = myB64.encode(privKey.getEncoded());
m_PublicKey = myB64.encode(pubKey.getEncoded());
}
catch(Exception ex){}
}
Edited by: mehala on Mar 6, 2008 9:17 AM