public class CryptoUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
protected CryptoStreamFactory |
cryptoStreamFactory |
| Modifier | Constructor and Description |
|---|---|
protected |
CryptoUtil() |
protected |
CryptoUtil(byte[] salt,
int count) |
| Modifier and Type | Method and Description |
|---|---|
static long |
copy(InputStream is,
OutputStream os)
Deprecated.
use StreamUtil instead
|
protected void |
decrypt(CryptoStreamFactory factory,
Object source,
Object target,
char[] password)
Copies from a source to a target object using decryption and a caller-suppier
CryptoStreamFactory.
|
void |
decrypt(Object source,
Object target,
char[] password)
Copies from a source to a target object using decryption.
|
String |
decryptString(CryptoStreamFactory factory,
String cipherText,
char[] password)
Decrypts an encrypted string into the plain text.
|
String |
decryptString(String cipherText,
char[] password)
Decrypts an encrypted string into the plain text.
|
String |
decryptString(String cipherText,
char[] password,
boolean withClearCode)
Decrypts an encrypted string into the plain text.
|
String |
decryptStringWithClearCode(String cipherText,
char[] password)
Decrypts an encrypted string into the plain text.
|
void |
encrypt(CryptoStreamFactory factory,
Object source,
Object target,
char[] password)
Copies from a source to a target object using encryption and a caller
supplied CryptoStreamFactory.
|
void |
encrypt(Object source,
Object target,
char[] password)
Copies from a source to a target object using encryption
|
String |
encryptString(CryptoStreamFactory factory,
String plainText,
char[] password,
boolean withClearCode)
Encrypts a string into a hex string.
|
String |
encryptString(String plainText,
char[] password)
Encrypts a string into a hex string.
|
String |
encryptStringWithClearCode(String plainText,
char[] password)
Encrypts a string into a hex string using
CryptoParametersJ8.CLEAR_CODE_DEFAULT |
CryptoStreamFactory |
getCryptoStreamFactory() |
static CryptoUtil |
getInstance()
Factory method to get a default instance
|
static CryptoUtil |
getInstance(byte[] salt,
int count)
Factory method to get a default instance
|
protected CryptoStreamFactory cryptoStreamFactory
protected CryptoUtil()
protected CryptoUtil(byte[] salt,
int count)
salt - the salt for the PBE algorithmcount - the iteration for PBEParameterSpecpublic static CryptoUtil getInstance()
public static CryptoUtil getInstance(byte[] salt, int count)
salt - the salt for the PBE algorithmcount - the iteration for PBEParameterSpecpublic void encrypt(Object source, Object target, char[] password) throws GeneralSecurityException, IOException
source - the source objecttarget - the target objectpassword - the password to use for encryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic void encrypt(CryptoStreamFactory factory, Object source, Object target, char[] password) throws GeneralSecurityException, IOException
factory - the factory to create the crypto streamssource - the source objecttarget - the target objectpassword - the password to use for encryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic String encryptStringWithClearCode(String plainText, char[] password) throws GeneralSecurityException, IOException
CryptoParametersJ8.CLEAR_CODE_DEFAULTplainText - the plain text to be encryptedpassword - the password for encryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic String encryptString(String plainText, char[] password) throws GeneralSecurityException, IOException
plainText - the plain text to be encryptedpassword - the password for encryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic String encryptString(CryptoStreamFactory factory, String plainText, char[] password, boolean withClearCode) throws GeneralSecurityException, IOException
factory - the factory to create the crypto streamsplainText - the plain text to be encryptedpassword - the password for encryptionwithClearCode - boolean to indicate, that a string containing how it was decoded is includedGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic void decrypt(Object source, Object target, char[] password) throws GeneralSecurityException, IOException
source - the source objecttarget - the target objectpassword - the password to use for decryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic String decryptStringWithClearCode(String cipherText, char[] password) throws GeneralSecurityException, IOException
CryptoParametersJ8.CLEAR_CODE_DEFAULT.
Removes ClearCode length of 10 bit, before decrpyting expected as prefix.cipherText - the encrypted text to be decryptedpassword - the password for decryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic String decryptString(String cipherText, char[] password) throws GeneralSecurityException, IOException
cipherText - the encrypted text to be decryptedpassword - the password for decryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic String decryptString(String cipherText, char[] password, boolean withClearCode) throws GeneralSecurityException, IOException
cipherText - the encrypted text to be decryptedpassword - the password for decryptionwithClearCode - boolean to indicate, that a string containing how it was decoded was included during encryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedprotected void decrypt(CryptoStreamFactory factory, Object source, Object target, char[] password) throws GeneralSecurityException, IOException
factory - the factory to create the crypto streamssource - the source objecttarget - the target objectpassword - the password to use for decryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic String decryptString(CryptoStreamFactory factory, String cipherText, char[] password) throws GeneralSecurityException, IOException
factory - the factory to create the crypto streamscipherText - the encrypted text to be decryptedpassword - the password for decryptionGeneralSecurityException - accessing JCE failedIOException - accessing the souce failedpublic static long copy(InputStream is, OutputStream os) throws IOException
is - the source input streamos - the target output streamIOException - the copying failedpublic CryptoStreamFactory getCryptoStreamFactory()
Copyright © 2008–2020 The Apache Software Foundation. All rights reserved.