Class EncryptionServices

java.lang.Object
com.ebasetech.xi.services.EncryptionServices
All Implemented Interfaces:
java.io.Serializable

public class EncryptionServices
extends java.lang.Object
implements java.io.Serializable
Encryption and decryption services
Since:
V4.4
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor Description
    EncryptionServices()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String decrypt​(java.lang.String message)
    Deprecated.
    from V5.3 use decryptAES(String) instead
    static java.lang.String decrypt​(java.lang.String message, int count, java.lang.String key)
    Deprecated.
    from V5.3 use decryptAES(String, String) instead
    static java.lang.String decryptAES​(java.lang.String message)
    Decrypts a Base64 encoded string represented by message using the AES algorithm and a 128 bit key with default encryption parameters.
    static java.lang.String decryptAES​(java.lang.String message, java.lang.String key)
    Decrypts a Base64 encoded string represented by message using the AES algorithm and a 128 bit key.
    static java.lang.String decryptAES​(java.lang.String message, java.lang.String key, int iterations)
    Decrypts a Base64 encoded string represented by message using the AES algorithm and a 128 bit key.
    static java.lang.String encrypt​(java.lang.String message)
    Deprecated.
    from V5.3 use encryptAES(String) instead
    static java.lang.String encrypt​(java.lang.String message, int count, java.lang.String key)
    Deprecated.
    from V5.3 use encryptAES(String, String) instead
    static java.lang.String encryptAES​(java.lang.String message)
    Returns a Base64 encoded Encrypted string represented by message using the AES algorithm and a 128 bit key with default encryption parameters.
    static java.lang.String encryptAES​(java.lang.String message, java.lang.String key)
    Returns a Base64 encoded Encrypted string represented by message using the AES algorithm and a 128 bit key.
    static java.lang.String encryptAES​(java.lang.String message, java.lang.String key, int iterations)
    Returns a Base64 encoded Encrypted string represented by message using the AES algorithm and a 128 bit key.
    static java.lang.String generateHash​(java.lang.String message, int iterations, java.lang.String salt)
    Hashes a string represented by message using the PBKDF2WithHmacSHA512 algorithm and a 512 bit key.
    static java.lang.String generateRandomSalt​(int bytes)
    Generates a salt suitable for generateHash.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EncryptionServices

      public EncryptionServices()
  • Method Details

    • generateHash

      public static java.lang.String generateHash​(java.lang.String message, int iterations, java.lang.String salt) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Hashes a string represented by message using the PBKDF2WithHmacSHA512 algorithm and a 512 bit key.
      Parameters:
      message - The message to be hashed
      iterations - The iterations argument specifies how many times the PBKDF2 executes its underlying algorithm. A higher value is safer
      salt - should be random data and vary for each user. Remember to save the salt with the hashed password
      Returns:
      Base64 encoded hashed string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      v5.3
    • generateRandomSalt

      public static java.lang.String generateRandomSalt​(int bytes) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Generates a salt suitable for generateHash.
      Parameters:
      bytes - the number of bytes in the salt. e.g. 32
      Returns:
      A random byte array encoded as Base64. Will be longer than number of bytes.
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException
    • encryptAES

      public static java.lang.String encryptAES​(java.lang.String message, java.lang.String key, int iterations) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Returns a Base64 encoded Encrypted string represented by message using the AES algorithm and a 128 bit key.
      Parameters:
      message - string to be encrypted
      key - key used by the encryption algorithm; if null, the default is used (see encryptAES(String))
      iterations - number of times to encrypt the string. This number must be 1 or greater
      Returns:
      Base64 encoded encrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      V5.3
      See Also:
      encryptAES(String), encryptAES(String, String)
    • encryptAES

      public static java.lang.String encryptAES​(java.lang.String message, java.lang.String key) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Returns a Base64 encoded Encrypted string represented by message using the AES algorithm and a 128 bit key.
      Parameters:
      message - string to be encrypted
      key - key used by the encryption algorithm; if null, the default is used (see encryptAES(String))
      Returns:
      Base64 encoded encrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      V5.3
      See Also:
      encryptAES(String)
    • encryptAES

      public static java.lang.String encryptAES​(java.lang.String message) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Returns a Base64 encoded Encrypted string represented by message using the AES algorithm and a 128 bit key with default encryption parameters.
      Parameters:
      message - the string to be encrypted
      Returns:
      Base64 encoded encrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      V5.3
      See Also:
      encryptAES(String, String)
    • decryptAES

      public static java.lang.String decryptAES​(java.lang.String message, java.lang.String key, int iterations) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Decrypts a Base64 encoded string represented by message using the AES algorithm and a 128 bit key.
      Parameters:
      message - Base64 encoded string to be decrypted
      key - key used by the decrytion algorithm; if null, the default is used (see decryptAES(String))
      iterations - number of times to decrypt the encrypted string. The number of iterations must match the iterations when encrypting the string.
      Returns:
      decrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs, usually the message is not in the correct encrypted format
      Since:
      V5.3
      See Also:
      decryptAES(String), decryptAES(String, String), encryptAES(String, String, int)
    • decryptAES

      public static java.lang.String decryptAES​(java.lang.String message, java.lang.String key) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Decrypts a Base64 encoded string represented by message using the AES algorithm and a 128 bit key.
      Parameters:
      message - Base64 encoded string to be decrypted
      key - key used by the decrytion algorithm; if null, the default is used (see decryptAES(String))
      Returns:
      decrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs, usually the message is not in the correct encrypted format
      Since:
      V5.3
      See Also:
      decryptAES(String)
    • decryptAES

      public static java.lang.String decryptAES​(java.lang.String message) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Decrypts a Base64 encoded string represented by message using the AES algorithm and a 128 bit key with default encryption parameters.
      Parameters:
      message - the string to be decrypted
      Returns:
      decrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs, usually the message is not in the correct encrypted format
      Since:
      V5.3
      See Also:
      decryptAES(String, String)
    • encrypt

      @Deprecated public static java.lang.String encrypt​(java.lang.String message, int count, java.lang.String key) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Deprecated.
      from V5.3 use encryptAES(String, String) instead
      Encrypts the string represented by message using the PBEWithMD5AndDES algorithm.
      Parameters:
      message - string to be encrypted
      count - number of times the encryption algorithm is invoked
      key - key used by the encryption algorithm; if null, the default is used (see encrypt(String))
      Returns:
      encrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      V4.4
      See Also:
      encrypt(String)
    • encrypt

      @Deprecated public static java.lang.String encrypt​(java.lang.String message) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Deprecated.
      from V5.3 use encryptAES(String) instead
      Encrypts the string represented by message using the PBEWithMD5AndDES algorithm and with default encryption parameters.
      Parameters:
      message - the string to be encrypted
      Returns:
      encrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      V4.4
      See Also:
      encrypt(String, int, String)
    • decrypt

      @Deprecated public static java.lang.String decrypt​(java.lang.String message, int count, java.lang.String key) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Deprecated.
      from V5.3 use decryptAES(String, String) instead
      Decrypts the string represented by message using the PBEWithMD5AndDES algorithm.
      Parameters:
      message - string to be decrypted
      count - number of times the encryption algorithm is invoked
      key - key used by the decrytion algorithm; if null, the default is used (see decrypt(String))
      Returns:
      decrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs, usually the message is not in the correct encrypted format
      Since:
      V4.4
      See Also:
      decrypt(String)
    • decrypt

      @Deprecated public static java.lang.String decrypt​(java.lang.String message) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Deprecated.
      from V5.3 use decryptAES(String) instead
      Decrypts the string represented by message using the PBEWithMD5AndDES algorithm and with default encryption parameters.
      Parameters:
      message - the string to be decrypted
      Returns:
      decrypted string
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs, usually the message is not in the correct encrypted format
      Since:
      V4.4
      See Also:
      decrypt(String, int, String)