-
- All Implemented Interfaces:
public class RSAConverter
Several conversion functions for RSA and PEM keys
-
-
Method Summary
Modifier and Type Method Description static String
publicToPEM(PublicKey publicKey)
Convert a public RSA key to a PEM key. static String
privateToPEM(PrivateKey privateKey)
Convert a private RSA key to a PEM key. static Array<byte>
pemToBytes(String pem)
Convert a PEM key to a byte array. static PublicKey
bytesToPublicKey(Array<byte> bytes)
Convert bytes to an RSA public key. static PrivateKey
bytesToPrivateKey(Array<byte> bytes)
Convert bytes to an RSA private key. static KeyPair
privateKeyToKeyPair(PrivateKey privateKey)
Convert a private RSA key to a KeyPair with the public key. static Array<byte>
getBytes(PrivateKey key)
Convert a private RSA key to static Array<byte>
getBytes(PublicKey key)
Convert a public RSA key to -
-
Method Detail
-
publicToPEM
static String publicToPEM(PublicKey publicKey)
Convert a public RSA key to a PEM key.
- Parameters:
publicKey
- The public key to convert.
-
privateToPEM
static String privateToPEM(PrivateKey privateKey)
Convert a private RSA key to a PEM key.
- Parameters:
privateKey
- The private key to convert.
-
pemToBytes
static Array<byte> pemToBytes(String pem)
Convert a PEM key to a byte array. They key isn't checked before conversion!
- Parameters:
pem
- The PEM key to convert to a byte array.
-
bytesToPublicKey
static PublicKey bytesToPublicKey(Array<byte> bytes)
Convert bytes to an RSA public key.
- Parameters:
bytes
- The bytes to convert.
-
bytesToPrivateKey
static PrivateKey bytesToPrivateKey(Array<byte> bytes)
Convert bytes to an RSA private key.
- Parameters:
bytes
- The bytes to convert.
-
privateKeyToKeyPair
static KeyPair privateKeyToKeyPair(PrivateKey privateKey)
Convert a private RSA key to a KeyPair with the public key.
- Parameters:
privateKey
- The private RSA key.
-
getBytes
static Array<byte> getBytes(PrivateKey key)
Convert a private RSA key to
- Parameters:
key
- The private RSA key to convert.
-
-
-
-