public class PublicKeyEncryptor extends AbstractEncryptor<Cipher,PublicKey> implements de.alpharogroup.crypto.api.ByteArrayEncryptor
PublicKeyEncryptor can encrypt a byte array with his public key.model| Constructor and Description |
|---|
PublicKeyEncryptor(de.alpharogroup.crypto.model.CryptModel<Cipher,PublicKey> model)
Instantiates a new
PublicKeyEncryptor with the given CryptModel. |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
encrypt(byte[] toEncrypt) |
protected String |
newAlgorithm()
Factory method for creating a new algorithm that will be used with the cipher object.
|
protected Cipher |
newCipher(PublicKey key,
String algorithm,
byte[] salt,
int iterationCount,
int operationMode)
Factory method for creating a new
Cipher from the given parameters. |
newOperationModenewAlgorithmParameterSpec, newCipher, newIterationCount, newSalt, newSecretKeyFactory, onInitializepublic PublicKeyEncryptor(de.alpharogroup.crypto.model.CryptModel<Cipher,PublicKey> model) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidAlgorithmParameterException, UnsupportedEncodingException
PublicKeyEncryptor with the given CryptModel.model - The crypt model.InvalidAlgorithmParameterException - is thrown if initialization of the cypher object fails.NoSuchPaddingException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeyException - is thrown if initialization of the cypher object fails.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.UnsupportedEncodingException - is thrown if the named charset is not supported.public byte[] encrypt(byte[] toEncrypt)
throws Exception
encrypt in interface de.alpharogroup.crypto.api.Encryptor<byte[],byte[]>Exceptionprotected String newAlgorithm()
newAlgorithm in class AbstractCryptor<Cipher,PublicKey>protected Cipher newCipher(PublicKey key, String algorithm, byte[] salt, int iterationCount, int operationMode) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, UnsupportedEncodingException
Cipher from the given parameters. This method is
invoked in the constructor from the derived classes and can be overridden so users can
provide their own version of a new Cipher from the given parameters.newCipher in class AbstractCryptor<Cipher,PublicKey>key - the keyalgorithm - the algorithmsalt - the salt.iterationCount - the iteration countoperationMode - the operation mode for the new cipher objectNoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchPaddingException - is thrown if instantiation of the cypher object fails.InvalidKeyException - is thrown if initialization of the cypher object fails.InvalidAlgorithmParameterException - is thrown if initialization of the cypher object fails.UnsupportedEncodingException - is thrown if the named charset is not supported.Copyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.