public class RsaCipher extends java.lang.Object implements EncryptionCipher, DecryptionCipher
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PRIVATE_KEY_FILENAME |
static java.lang.String |
PUBLIC_KEY_FILENAME |
Constructor and Description |
---|
RsaCipher(java.io.File keyDirectory) |
Modifier and Type | Method and Description |
---|---|
byte[] |
decrypt(byte[] data)
Decrypts the specified data.
|
byte[] |
encrypt(byte[] data)
Encrypts the specified data.
|
byte[] |
encrypt(byte[] data,
java.security.PublicKey publicKey) |
byte[] |
getPublicKey() |
void |
init()
Initializes the cipher instance.
|
public static final java.lang.String PRIVATE_KEY_FILENAME
public static final java.lang.String PUBLIC_KEY_FILENAME
public void init() throws java.lang.Exception
EncryptionCipher
init
in interface DecryptionCipher
init
in interface EncryptionCipher
java.lang.Exception
public byte[] decrypt(byte[] data) throws java.security.GeneralSecurityException
DecryptionCipher
decrypt
in interface DecryptionCipher
data
- the data to decrypt.java.security.GeneralSecurityException
public byte[] encrypt(byte[] data) throws java.security.GeneralSecurityException
EncryptionCipher
encrypt
in interface EncryptionCipher
data
- the data to encrypt.java.security.GeneralSecurityException
public byte[] encrypt(byte[] data, java.security.PublicKey publicKey) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public byte[] getPublicKey()