Package convex.core.crypto
Class Symmetric
java.lang.Object
convex.core.crypto.Symmetric
Class providing symmetric encryption functionality using AES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SecretKey
Creates an AES secret keystatic byte[]
Decrypts AES ciphertext with a given secret key.static byte[]
decrypt
(SecretKey key, InputStream bis) Decrypts AES ciphertext with a given secret key.static String
decryptString
(SecretKey key, byte[] encryptedData) Decrypts a string from ciphertext, assuming UTF-8 format datastatic byte[]
Encrypt bytes with a given AES SecretKey Prepends the IV to the ciphertext.static byte[]
Encrypts a String with a given AES secret key, using standard UTF-8 encoding
-
Constructor Details
-
Symmetric
public Symmetric()
-
-
Method Details
-
encrypt
Encrypts a String with a given AES secret key, using standard UTF-8 encoding- Parameters:
key
- AES secret keydata
- String to encrypt- Returns:
- Encrypted representation of the given string
-
encrypt
Encrypt bytes with a given AES SecretKey Prepends the IV to the ciphertext.- Parameters:
key
- Secret encryption keydata
- Data to encrypt- Returns:
- Encrypted representation of the given byte array data
-
decryptString
Decrypts a string from ciphertext, assuming UTF-8 format data- Parameters:
key
- AES Secret KeyencryptedData
- encrypted byte[] data to decrypt (ciphertext)- Returns:
- The decrypted String
-
decrypt
Decrypts AES ciphertext with a given secret key. IV is assumed to be prepended to the cipherText- Parameters:
key
- Secret encryption keyencryptedData
- Encrypted data to decrypt- Returns:
- A new byte array containing the decrypted data
-
decrypt
Decrypts AES ciphertext with a given secret key. IV is assumed to be prepended to the cipherText- Parameters:
key
- Secret encryption keybis
- InputStream of data to decrypt- Returns:
- A new byte array containing the decrypted data
- Throws:
IOException
- If an IO error occurs
-
createSecretKey
Creates an AES secret key- Returns:
- The generated SecretKey
-