public class StringEncrypter2
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private static java.util.Base64.Decoder |
cvDecoder
The base 64 decoder used for converting strings to byte arrays.
|
private static javax.crypto.Cipher |
cvDecryptCipher
The cipher for decryption.
|
private static java.util.Base64.Encoder |
cvEncoder
The base 64 encoder used for converting byte arrays to strings.
|
private static javax.crypto.Cipher |
cvEncryptCipher
The cipher for encryption.
|
private static javax.crypto.spec.SecretKeySpec |
cvKeySpec
The key used for encryption and decryption.
|
private static java.security.SecureRandom |
RANDOM
The random number generator used for initialization vectors.
|
private static long |
serialVersionUID
The class' serialization version id.
|
Constructor and Description |
---|
StringEncrypter2() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decrypt(java.lang.String s,
java.lang.String iv)
Decrypts the given string.
|
static java.lang.String |
encrypt(java.lang.String s,
java.lang.String iv)
Encrypts the given string.
|
static java.lang.String |
getRandomIV()
Returns a random generated initialization vector.
|
static boolean |
isCryptoInstalled()
Answers if the cryptography supporting classes are installed.
|
private static final long serialVersionUID
private static final java.security.SecureRandom RANDOM
private static java.util.Base64.Encoder cvEncoder
private static java.util.Base64.Decoder cvDecoder
private static javax.crypto.spec.SecretKeySpec cvKeySpec
private static javax.crypto.Cipher cvEncryptCipher
private static javax.crypto.Cipher cvDecryptCipher
public static java.lang.String decrypt(java.lang.String s, java.lang.String iv)
encrypt
method of this class. Returns the same string if the
cryptography classes are not installed.s
- (String) The string to be decrypted.iv
- (String) The initialization vector that was originally used
to encrypt the string.public static java.lang.String encrypt(java.lang.String s, java.lang.String iv)
decrypt
method of this class. Returns the same string if the cryptography
classes are not installed.s
- (String) The string to be encrypted.iv
- (String) The initialization vector to use for encryption.public static java.lang.String getRandomIV()
public static boolean isCryptoInstalled()
true
if the cryptography classes are
installed, otherwise false
.