public class EncryptUtil
extends java.lang.Object
The Key is being generated using the Password-based-Key-Derivative-Function with Keyed-Hash Message Authentication Code and Secure Hash Algorithm 1 (PBKDF2WithHmacSHA1).
Constructor and Description |
---|
EncryptUtil(java.lang.String key)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
EncryptUtil |
decrypt(byte[] dataToDecrypt)
Chained method used to Decrypt the provided Data (byte[]).
|
EncryptUtil |
decrypt(java.io.File fileToDecrypt)
Chained method used to Decrypt the provided File object.
|
EncryptUtil |
decrypt(java.nio.file.Path pathToDecrypt)
Chained method used to Decrypt the provided Path object.
|
EncryptUtil |
decrypt(java.lang.String textToDecrypt)
Chained method used to Decrypt the provided text.
|
EncryptUtil |
encrypt(byte[] dataToEncrypt)
Chained method used to Encrypt the provided Data (byte[]).
|
EncryptUtil |
encrypt(java.io.File fileToEncrypt)
Chained method used to Encrypt the provided File object.
|
EncryptUtil |
encrypt(java.nio.file.Path pathToEncrypt)
Chained method used to Encrypt the provided Path object.
|
EncryptUtil |
encrypt(java.lang.String textToEncrypt)
Chained method used to Encrypt the provided text.
|
byte[] |
getBytes()
This method will return the encrypted/decrypted data.
|
java.lang.String |
toString()
This method will use the encrypted/decrypted data (bytes[]) to convert it to a String representation.
|
void |
writeFile()
This method will write the encrypted/decrypted data (byte[]) into the provided File.
|
static void |
writeFile(byte[] fileBytes,
java.io.File file)
Helper method to write the data in the provided File.
|
static void |
writeFile(byte[] fileBytes,
java.nio.file.Path path)
Helper method to write the data in the provided Path.
|
public EncryptUtil(java.lang.String key)
key
- The Key to Encrypt/Decrypt the data.public static void writeFile(byte[] fileBytes, java.io.File file) throws java.io.IOException
fileBytes
- The data to write.file
- The file to write the data.java.io.IOException
- In case of IOException.public static void writeFile(byte[] fileBytes, java.nio.file.Path path) throws java.io.IOException
fileBytes
- The data to write.path
- The Path to write the data.java.io.IOException
- In case of IOException.public EncryptUtil encrypt(java.lang.String textToEncrypt) throws EncryptUtilException
textToEncrypt
- Text to encrypt.EncryptUtilException
- In case of EncryptUtilException.public EncryptUtil decrypt(java.lang.String textToDecrypt) throws EncryptUtilException
textToDecrypt
- Text to decrypt.EncryptUtilException
- In case of EncryptUtilException.public EncryptUtil encrypt(java.nio.file.Path pathToEncrypt) throws EncryptUtilException
pathToEncrypt
- The Path with the file location to encrypt.EncryptUtilException
- In case of EncryptUtilException.public EncryptUtil decrypt(java.nio.file.Path pathToDecrypt) throws EncryptUtilException
pathToDecrypt
- The Path with the file location to decrypt.EncryptUtilException
- In case of EncryptUtilException.public EncryptUtil encrypt(java.io.File fileToEncrypt) throws EncryptUtilException
fileToEncrypt
- The File object with the location to encrypt.EncryptUtilException
- In case of EncryptUtilException.public EncryptUtil decrypt(java.io.File fileToDecrypt) throws EncryptUtilException
fileToDecrypt
- The File object with the location to decrypt.EncryptUtilException
- In case of EncryptUtilException.public EncryptUtil encrypt(byte[] dataToEncrypt) throws EncryptUtilException
dataToEncrypt
- The Data (byte[]) to encrypt.EncryptUtilException
- In case of EncryptUtilException.public EncryptUtil decrypt(byte[] dataToDecrypt) throws EncryptUtilException
dataToDecrypt
- The Data (byte[]) to encrypt.EncryptUtilException
- In case of EncryptUtilException.public java.lang.String toString()
toString
in class java.lang.Object
public byte[] getBytes()
public void writeFile() throws java.io.IOException
java.io.IOException
- In case of IOException.