Class CipherUtil

java.lang.Object
com.webmethods.caf.common.CipherUtil

public final class CipherUtil extends Object
Provides simple encrypt/decrypt functionality for the portal.
  • Constructor Details

    • CipherUtil

      public CipherUtil()
  • Method Details

    • hash

      public static String hash(String value) throws UnsupportedEncodingException
      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

      public static String hash(String value, boolean forceHash) throws UnsupportedEncodingException
      Calculates SHA2 algorithm hash value
      Parameters:
      value - input to be encrypted
      forceHash - encrypts value if true
      Throws:
      UnsupportedEncodingException
    • hashBytes

      public static String hashBytes(byte[] value)
      Calculates SHA2 algorithm hash value
      Parameters:
      value - input to be encrypted
    • hashEquals

      public static boolean hashEquals(String hash, String value) throws UnsupportedEncodingException
      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 value
      value - input checked if it exists in hash
      Throws:
      UnsupportedEncodingException
    • isHash

      public static boolean isHash(String hash)
      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

      public static String encrypt(String value) throws Exception
      Encrypts simple string value
      Parameters:
      value - input to be encrypted
      Returns:
      encrypted value of input
      Throws:
      Exception
    • isEncrypted

      public static boolean isEncrypted(String value)
      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

      public static String decrypt(String value) throws Exception
      Decrypts simple value
      Parameters:
      value - decrypts if value is valid SHA hash
      Returns:
      uncrypted value of input
      Throws:
      Exception
    • main

      public static void main(String[] argv) throws Exception
      main method used to encrypt an input at runtime.
      Parameters:
      argv - value to encrypt
      Throws:
      Exception
    • getSecureString

      public static String getSecureString(String key) throws ClassNotFoundException, IOException
      Throws:
      ClassNotFoundException
      IOException