public final class CryptoStreamPBEImpl extends CryptoStreamFactoryJ8Template
CryptoParametersJ8 ALGORITHM_J8_PBE for encryption which
should be sufficient for most applications.
The implementation also supplies a default password in the case that
the programmer don't want to have additional hassles. It is easy to
re-engineer the password being used but much better than a hard-coded
password in the application.
The code uses parts from Markus Hahn's Blowfish library found at
http://blowfishj.sourceforge.net/CryptoParametersJ8.TYPES PBE.| Modifier and Type | Field and Description |
|---|---|
protected static int |
COUNT_J8
default count for pbe spec
|
protected static int |
IV_SIZE |
protected static int |
KEY_SIZE |
algorithm, count, instances, providerName, PROVIDERNAME, salt, SALT_SIZE| Constructor and Description |
|---|
CryptoStreamPBEImpl()
Constructor
count is set to
COUNT_J8. |
CryptoStreamPBEImpl(byte[] salt)
Constructor
|
CryptoStreamPBEImpl(byte[] salt,
int count)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
createCipher(InputStream is,
int mode,
char[] password)
Create a Cipher.
|
protected Key |
createKey(char[] password,
byte[] salt)
Create a PBE key.
|
generateSalt, getAlgorithm, getCount, getInputStream, getInputStream, getInputStream, getInputStream, getInstance, getInstance, getInstance, getOutputStream, getOutputStream, getOutputStream, getProviderName, getSalt, getSmartInputStream, getSmartInputStream, getType, resetInstances, setAlgorithm, setCount, setProviderName, setSalt, setTypeprotected static final int IV_SIZE
protected static final int KEY_SIZE
protected static final int COUNT_J8
public CryptoStreamPBEImpl()
throws GeneralSecurityException
COUNT_J8.GeneralSecurityException - if no algo could be found.public CryptoStreamPBEImpl(byte[] salt)
salt - the salt for the PBE algorithmpublic CryptoStreamPBEImpl(byte[] salt,
int count)
salt - the salt for the PBE algorithmcount - the iteration for PBEParameterSpecprotected Key createKey(char[] password, byte[] salt) throws GeneralSecurityException
createKey in class CryptoStreamFactoryJ8Templatepassword - the password to use.salt - if provided this is used, otherweise CryptoStreamFactoryJ8Template.getSalt().GeneralSecurityException - if creating the key failedprotected byte[] createCipher(InputStream is, int mode, char[] password) throws GeneralSecurityException, IOException
PBEParameterSpec.createCipher in class CryptoStreamFactoryJ8Templatemode - the cipher modepassword - the passwordis - the input streamGeneralSecurityException - creating a cipher failedIOException - creating a cipher failedCopyright © 2008–2020 The Apache Software Foundation. All rights reserved.