public final class CipherUtil extends Object
Constructor and Description |
---|
CipherUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
decrypt(String value)
Decrypts simple value
|
static String |
encrypt(String value)
Encrypts simple string value
|
static String |
hash(String value)
Calculates SHA2 algorithm hash value
|
static String |
hash(String value,
boolean forceHash)
Calculates SHA2 algorithm hash value
|
static String |
hashBytes(byte[] value)
Calculates SHA2 algorithm hash value
|
static boolean |
hashEquals(String hash,
String value)
Checks if specified value hash is the same as passed in hash.
|
static boolean |
isEncrypted(String value)
Returns true if passed value is encrypted
|
static boolean |
isHash(String hash)
Returns true if the passed hash value does represent a valid SHA hash
value
|
static void |
main(String[] argv)
main method used to encrypt an input at runtime.
|
public static String hash(String value) throws UnsupportedEncodingException
value
- input to be encryptedUnsupportedEncodingException
- error if the character encoding is not supported.public static String hash(String value, boolean forceHash) throws UnsupportedEncodingException
value
- input to be encryptedforceHash
- encrypts value if trueUnsupportedEncodingException
public static String hashBytes(byte[] value)
value
- input to be encryptedpublic static boolean hashEquals(String hash, String value) throws UnsupportedEncodingException
hash
- input being compared to valuevalue
- input checked if it exists in hashUnsupportedEncodingException
public static boolean isHash(String hash)
hash
- input being being checked if it is a valid SHA hash valuepublic static String encrypt(String value) throws Exception
value
- input to be encryptedException
public static boolean isEncrypted(String value)
value
- String to be checked if it is currently encryptedpublic static String decrypt(String value) throws Exception
value
- decrypts if value is valid SHA hashException