@ThreadSafe @Immutable public class Crypt extends Object
| Modifier and Type | Field and Description |
|---|---|
static Crypt |
AES128
The encryption algorithm AES with 128 Bits key size.
|
static Crypt |
AES192
The encryption algorithm AES with 192 Bits key size.
|
static Crypt |
AES256
The encryption algorithm AES with 256 Bits key size.
|
static Crypt |
Blowfish128
Bruce Schneiers encryption algorithm Blowfish with 128 Bits key size.
|
static Crypt |
Blowfish192
Bruce Schneiers encryption algorithm Blowfish with 192 Bits key size.
|
static Crypt |
Blowfish256
Bruce Schneiers encryption algorithm Blowfish with 256 Bits key size.
|
static Crypt |
DES192
The encryption algorithm Triple-DES with 192 Bits key size (effective key size 168 bits,
the effective key size for brute force is smaller than 168 bits).
|
static Crypt |
DES64
The encryption algorithm DES with 64 Bits key size (effective key size 56 bits!).
|
| Constructor and Description |
|---|
Crypt(String encryptionAlgorithm,
int keySize,
int blockSize)
Constructs a Crypt object with the specified parameters.
|
Crypt(String encryptionAlgorithm,
int keySize,
int blockSize,
String passwordHashingAlgorithm)
Constructs a Crypt object with the specified parameters.
|
Crypt(String encryptionAlgorithm,
int keySize,
int blockSize,
String passwordHashingAlgorithm,
String blockMode,
String padding)
Constructs a Crypt object with the specified parameters
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] input,
byte[] passwordBytes)
Decrypts the input data and returns the plain text
|
byte[] |
decrypt(byte[] input,
String password)
Decrypts the input data and returns the plain text
|
long |
decrypt(InputStream input,
OutputStream output,
byte[] passwordBytes)
Decrypts all input from the given input stream to the given output stream.
|
long |
decrypt(InputStream input,
OutputStream output,
String password)
Decrypts all input from the given input stream to the given outputs tream.
|
byte[] |
encrypt(byte[] input,
byte[] passwordBytes)
Encrypts the input data and returns the cipher text
|
byte[] |
encrypt(byte[] input,
String password)
Encrypts the input data and returns the cipher text
|
long |
encrypt(InputStream input,
OutputStream output,
byte[] passwordBytes)
Encrypts all input from the given input stream to the given output stream.
|
long |
encrypt(InputStream input,
OutputStream output,
String password)
Encrypts all input from the given input stream to the given output stream.
|
int |
getBlockSize()
Returns the block size in bits
|
byte[] |
getHashedEncryptionKey(String password)
Hashes an password string
|
int |
getKeySize()
Returns the key size in bits
|
public static final Crypt AES256
public static final Crypt AES192
public static final Crypt AES128
public static final Crypt Blowfish256
public static final Crypt Blowfish192
public static final Crypt Blowfish128
public static final Crypt DES64
public static final Crypt DES192
public Crypt(@Nonnull String encryptionAlgorithm, int keySize, int blockSize, @Nonnull String passwordHashingAlgorithm, @Nonnull String blockMode, @Nonnull String padding)
encryptionAlgorithm - the encryption algorithm (see http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html)keySize - the key size in bits. Compatibility to the encryption algorithm is not checked!blockSize - the block size in bits. Compatibility to the encryption algorithm is not checked!passwordHashingAlgorithm - the password hashing algorithm for String passwordsblockMode - the block encoding mode. Modes other than CBC are not always supported. ECB is strongly discouragedpadding - the padding mode (see http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html)public Crypt(@Nonnull String encryptionAlgorithm, int keySize, int blockSize, @Nonnull String passwordHashingAlgorithm)
encryptionAlgorithm - the encryption algorithm (see http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html)keySize - the key size in bits. Compatibility to the encryption algorithm is not checked!blockSize - the block size in bits. Compatibility to the encryption algorithm is not checked!passwordHashingAlgorithm - the password hashing algorithm for String passwordspublic Crypt(@Nonnull String encryptionAlgorithm, int keySize, int blockSize)
encryptionAlgorithm - the encryption algorithm (see http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html)keySize - the key size in bits. Compatibility to the encryption algorithm is not checked!blockSize - the block size in bits. Compatibility to the encryption algorithm is not checked!public int getKeySize()
public int getBlockSize()
public long encrypt(@Nonnull@WillNotClose InputStream input, @Nonnull@WillClose OutputStream output, @Nonnull String password) throws IOException
input - plain text input streamoutput - cipher text output streampassword - password for encryption. The password used actually used will be the hash of this String using
the specified password hashing algorithmIOException - in case of an underlying IOException of the streamspublic long encrypt(@Nonnull@WillNotClose InputStream input, @Nonnull@WillClose OutputStream output, @Nonnull byte[] passwordBytes) throws IOException
input - plain text input streamoutput - cipher text output streampasswordBytes - the used password. The length must be compatible to the used encryption algorithmIOException - in case of an underlying IOException of the streamspublic long decrypt(@Nonnull@WillNotClose InputStream input, @Nonnull@WillClose OutputStream output, @Nonnull String password) throws IOException
input - cipher text input streamoutput - plain text output streampassword - password for decryption. The password used actually used will be the hash of this String using
the specified password hashing algorithmIOException - in case of an underlying IOException of the streamspublic long decrypt(@Nonnull@WillNotClose InputStream input, @Nonnull@WillClose OutputStream output, @Nonnull byte[] passwordBytes) throws IOException
input - cipher text input streamoutput - plain text output streampasswordBytes - the used password. The length must be compatible to the used encryption algorithmIOException - in case of an underlying IOException of the streams@Nonnull public byte[] encrypt(@Nonnull byte[] input, @Nonnull String password)
input - plain textpassword - password for encryption. The password used actually used will be the hash of this String using
the specified password hashing algorithm@Nonnull public byte[] encrypt(@Nonnull byte[] input, @Nonnull byte[] passwordBytes)
input - plain textpasswordBytes - the used password. The length must be compatible to the used encryption algorithm@Nonnull public byte[] decrypt(@Nonnull byte[] input, @Nonnull String password)
input - cipher textpassword - password for decryption. The password used actually used will be the hash of this String using
the specified password hashing algorithm@Nonnull public byte[] decrypt(@Nonnull byte[] input, @Nonnull byte[] passwordBytes)
input - cipher textpasswordBytes - the used password. The length must be compatible to the used encryption algorithmCopyright © 2014. All rights reserved.