Package com.webmethods.caf.common
Class CipherUtil
java.lang.Object
com.webmethods.caf.common.CipherUtil
Provides simple encrypt/decrypt functionality for the portal.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Decrypts simple valuestatic String
Encrypts simple string valuestatic String
getSecureString
(String key) static String
Calculates SHA2 algorithm hash valuestatic String
Calculates SHA2 algorithm hash valuestatic String
hashBytes
(byte[] value) Calculates SHA2 algorithm hash valuestatic 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 encryptedstatic boolean
Returns true if the passed hash value does represent a valid SHA hash valuestatic void
main method used to encrypt an input at runtime.
-
Constructor Details
-
CipherUtil
public CipherUtil()
-
-
Method Details
-
hash
Calculates SHA2 algorithm hash value- Parameters:
value
- input to be encrypted- Returns:
- hashed value of input
- Throws:
UnsupportedEncodingException
- error if the character encoding is not supported.
-
hash
Calculates SHA2 algorithm hash value- Parameters:
value
- input to be encryptedforceHash
- encrypts value if true- Throws:
UnsupportedEncodingException
-
hashBytes
Calculates SHA2 algorithm hash value- Parameters:
value
- input to be encrypted
-
hashEquals
Checks if specified value hash is the same as passed in hash. If passed in hash is a plain text String, then it simply compares value and hash.- Parameters:
hash
- input being compared to valuevalue
- input checked if it exists in hash- Throws:
UnsupportedEncodingException
-
isHash
Returns true if the passed hash value does represent a valid SHA hash value- Parameters:
hash
- input being being checked if it is a valid SHA hash value
-
encrypt
Encrypts simple string value- Parameters:
value
- input to be encrypted- Returns:
- encrypted value of input
- Throws:
Exception
-
isEncrypted
Returns true if passed value is encrypted- Parameters:
value
- String to be checked if it is currently encrypted- Returns:
- true if value is encrypted
-
decrypt
Decrypts simple value- Parameters:
value
- decrypts if value is valid SHA hash- Returns:
- uncrypted value of input
- Throws:
Exception
-
main
main method used to encrypt an input at runtime.- Parameters:
argv
- value to encrypt- Throws:
Exception
-
getSecureString
- Throws:
ClassNotFoundException
IOException
-