|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sshtools.publickey.SshKeyPairGenerator
Generate public/private key pairs.
To generate a new pair use the following code
To create formatted key file for the public key use:SshKeyPair pair = SshKeyPairGenerator.generateKeyPair(SshKeyPairGenerator.SSH2_RSA, 1024);
SshPublicKeyFile pubfile = SshPublicKeyFileFactory.create(pair.getPublicKey(), "Some comment", SshPublicKeyFileFactory.OPENSSH_FORMAT); FileOutputStream fout = new FileOutputStream("mykey.pub"); fout.write(pubfile.getFormattedKey()); fout.close();To create a formatted, encrypted private key file use:SshPrivateKeyFile prvfile = SshPrivateKeyFileFactory.create(pair, "my passphrase", "Some comment", SshPrivateKeyFileFactory.OPENSSH_FORMAT); FileOutputStream fout = new FileOutputStream("mykey"); fout.write(prvfile.getFormattedKey()); fout.close();
- Author:
- Lee David Painter
Field Summary static java.lang.String
SSH1_RSA
static java.lang.String
SSH2_DSA
static java.lang.String
SSH2_RSA
Constructor Summary SshKeyPairGenerator()
Method Summary static SshKeyPair
generateKeyPair(java.lang.String algorithm, int bits)
Generates a new key pair.
Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail SSH1_RSA
public static final java.lang.String SSH1_RSA
- See Also:
- Constant Field Values
SSH2_RSA
public static final java.lang.String SSH2_RSA
- See Also:
- Constant Field Values
SSH2_DSA
public static final java.lang.String SSH2_DSA
- See Also:
- Constant Field Values
Constructor Detail SshKeyPairGenerator
public SshKeyPairGenerator()
Method Detail generateKeyPair
public static SshKeyPair generateKeyPair(java.lang.String algorithm, int bits) throws java.io.IOException
- Generates a new key pair.
- Parameters:
algorithm
-bits
-- Returns:
- Throws:
java.io.IOException
Overview Package Class Use Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
Copyright © 2003 3SP LTD. All Rights Reserved.