public final class AsymmetricAlgorithm extends Object implements EncryptionAlgorithm
Main implementation of encryption algorithms that use asymmetric key pair based on existing javax.crypto package.
This implementation can provide both encoding and decoding or only one of these functions depending on what key was provided during instantiation. Public key is needed for encryption, private key for decryption.
Inputs and outputs from this encryption are bytes represented in HEX string.
This class is immutable and can be considered thread safe. It is not allowed to extend this class to ensure it stays that way.
RSABuilder| Modifier | Constructor and Description |
|---|---|
protected |
AsymmetricAlgorithm(String cipherName,
CryptoKeyFactory publicKeyFactory,
CryptoKeyFactory privateKeyFactory,
String encoding) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] input)
Decrypts specified array of bytes.
|
String |
decrypt(String input)
Decrypts specified input text using default UTF-8 encoding.
|
byte[] |
encrypt(byte[] input)
Encrypts specified array of bytes.
|
String |
encrypt(String input)
Encrypts specified input text.
|
protected AsymmetricAlgorithm(String cipherName, CryptoKeyFactory publicKeyFactory, CryptoKeyFactory privateKeyFactory, String encoding)
public byte[] encrypt(byte[] input)
throws EncryptionException
EncryptionAlgorithmencrypt in interface EncryptionAlgorithminput - input bytes to be encryptedEncryptionException - possible exception when encryption failspublic String encrypt(String input) throws EncryptionException
EncryptionAlgorithmencrypt in interface EncryptionAlgorithminput - input text to be encryptedEncryptionException - possible exception when encryption failspublic byte[] decrypt(byte[] input)
throws EncryptionException
EncryptionAlgorithmdecrypt in interface EncryptionAlgorithminput - input bytes to be decryptedEncryptionException - possible exception when decryption failspublic String decrypt(String input) throws EncryptionException
EncryptionAlgorithmdecrypt in interface EncryptionAlgorithminput - input text to be decryptedEncryptionException - possible exception when decryption failsCopyright © 2014. All rights reserved.