public class StringEncrypter
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private static java.util.Base64.Decoder |
cvDecoder
A base 64 decoder.
|
private static javax.crypto.Cipher |
cvDecryptCipher
The cipher for decryption.
|
private static java.util.Base64.Encoder |
cvEncoder
A base 64 encoder.
|
private static javax.crypto.Cipher |
cvEncryptCipher
The cipher for encryption.
|
private static javax.crypto.spec.PBEParameterSpec |
cvPbeParamSpec
The PBE parameter specification.
|
private static long |
serialVersionUID
The class' serialization version id.
|
Constructor and Description |
---|
StringEncrypter() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
byteToHexString(byte[] b)
Converts a byte array to a string of hex chars.
|
static java.lang.String |
decrypt(java.lang.String s)
Decrypts the given string.
|
static java.lang.String |
encrypt(java.lang.String s)
Encrypts the given string.
|
private static int |
fromDigit(char ch)
Returns the hex value of a character.
|
private static javax.crypto.SecretKey |
getSecretKey(java.lang.String trans,
java.lang.String pwd,
byte[] salt,
int count)
Generates the key used for encryption/decryption.
|
static byte[] |
hexStringToByte(java.lang.String hex)
Converts a string of hex to a byte array.
|
static boolean |
isCryptoInstalled()
Answers if the cryptography supporting classes are installed.
|
private static final long serialVersionUID
private static javax.crypto.spec.PBEParameterSpec cvPbeParamSpec
private static javax.crypto.Cipher cvEncryptCipher
private static javax.crypto.Cipher cvDecryptCipher
private static java.util.Base64.Encoder cvEncoder
private static java.util.Base64.Decoder cvDecoder
public static java.lang.String decrypt(java.lang.String s)
encrypt
method of this class. Returns the same string if the
cryptography classes are not installed.s
- (String) The string to be decrypted.public static java.lang.String encrypt(java.lang.String s)
decrypt
method of this class. Returns the same string if the cryptography
classes are not installed.s
- (String) The string to be encrypted.private static javax.crypto.SecretKey getSecretKey(java.lang.String trans, java.lang.String pwd, byte[] salt, int count)
trans
- (String) The encryption transformation parameter.pwd
- (String) The password.salt
- (byte[]) The salt.count
- (int) The count.public static java.lang.String byteToHexString(byte[] b)
b
- (byte[]) The byte values to convert.public static byte[] hexStringToByte(java.lang.String hex)
hex
- (String) A string of hex characters eg.: 0123456789abcdefprivate static int fromDigit(char ch)
ch
- (char) A character.public static boolean isCryptoInstalled()
true
if the cryptography classes are
installed, otherwise false
.