Package com.amilesend.client.crypto
Class CryptoHelper
java.lang.Object
com.amilesend.client.crypto.CryptoHelper
Helper that encrypts and decrypts content for the configured cipher algorithm and key.
Note: See Java Security Standard Algorithm Names for a list of available ciphers and be aware of which are applicable to comply with your local geographic laws and/or policies.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCryptoHelper
(String cipherAlgorithm, @NonNull SecretKey key) Creates a newCryptoHelper
instance. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
decrypt
(@NonNull EncryptedEnvelope envelope) Decrypts the givenEncryptedEnvelope
and returns the contents as a byte array.Encrypts the given bytes and returns anEncryptedEnvelope
.
-
Constructor Details
-
CryptoHelper
Creates a newCryptoHelper
instance.- Parameters:
cipherAlgorithm
- the cipher algorithm to usekey
- the key used to encrypt/decrypt content
-
-
Method Details
-
encrypt
public EncryptedEnvelope encrypt(@NonNull @lombok.NonNull byte[] content, String description) throws CryptoHelperException Encrypts the given bytes and returns anEncryptedEnvelope
.- Parameters:
content
- the content to encryptdescription
- a description of the content- Returns:
- the
EncryptedEnvelope
containing the encrypted bytes - Throws:
CryptoHelperException
- if an error occurred while encrypting the contents
-
decrypt
Decrypts the givenEncryptedEnvelope
and returns the contents as a byte array.- Parameters:
envelope
- the envelope to decrypt- Returns:
- the decrypted contents
- Throws:
CryptoHelperException
- if an error occurred while decrypting the envelope's contents
-