|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sshtools.publickey.SshKeyPairGenerator
public class SshKeyPairGenerator
Generate public/private key pairs.
To generate a new pair use the following code
SshKeyPair pair = SshKeyPairGenerator.generateKeyPair(SshKeyPairGenerator.SSH2_RSA,
1024);
To create formatted key file for the public key use:
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.StringSSH1_RSA
static java.lang.StringSSH2_DSA
static java.lang.StringSSH2_RSA
Constructor Summary SshKeyPairGenerator()
Method Summary static SshKeyPairgenerateKeyPair(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, SshException
- Generates a new key pair.
- Parameters:
algorithm-bits-- Returns:
- SshKeyPair
- Throws:
java.io.IOExceptionSshException
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-2008 SSHTools LTD. All Rights Reserved.