com.tibbo.aggregate.common.security

## Class KeyUtils

- java.lang.Object
- - com.tibbo.aggregate.common.security.KeyUtils

-     public class KeyUtils
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `REF_PHRASE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KeyUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `decryptKey(java.lang.String key)`
    `static java.lang.String` | `decryptPw(java.lang.String pw)`
    `static java.lang.String` | `decryptString(java.lang.String string)`
    `static java.lang.String` | `decryptStringBy(java.lang.String string, javax.crypto.spec.SecretKeySpec key)`
    `static byte[]` | `decryptStringToByteArray(java.lang.String string, javax.crypto.spec.SecretKeySpec keySpec)`
    `static java.lang.String` | `encryptByteArrayToString(byte[] string, javax.crypto.spec.SecretKeySpec keySpec)`
    `static java.lang.String` | `encryptKey(byte[] key)`
    `static java.lang.String` | `encryptPw(java.lang.String pw)`
    `static java.lang.String` | `encryptString(java.lang.String string)`
    `static java.lang.String` | `encryptStringBy(java.lang.String string, javax.crypto.spec.SecretKeySpec key)`
    `static void` | `eraseKeys()`
    `static void` | `generateInternalKey()`
    `static javax.crypto.spec.SecretKeySpec` | `getDecryptKey()`
    `static java.lang.String` | `getEncryptedInternalKey()`
    `static javax.crypto.spec.SecretKeySpec` | `getEncryptKey()`
    `static javax.crypto.spec.SecretKeySpec` | `getInternalKey()`
    `static javax.crypto.spec.SecretKeySpec` | `getLegacyInternalKey()`
    `static byte[]` | `getRandomKey()`
    `static void` | `init()`
    `static void` | `setKeys(byte[] oldEncryptionKey, byte[] newEncryptionKey)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### REF_PHRASE

          public static final java.lang.String REF_PHRASE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### KeyUtils

          public KeyUtils()

  - ### Method Detail

    - #### generateInternalKey

          public static void generateInternalKey()
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### init

          public static void init()

    - #### encryptByteArrayToString

          public static java.lang.String encryptByteArrayToString(byte[] string,
                                                                  javax.crypto.spec.SecretKeySpec keySpec)
                                                           throws java.security.GeneralSecurityException

      Throws:
        `java.security.GeneralSecurityException`

    - #### decryptStringToByteArray

          public static byte[] decryptStringToByteArray(java.lang.String string,
                                                        javax.crypto.spec.SecretKeySpec keySpec)
                                                 throws java.security.GeneralSecurityException

      Throws:
        `java.security.GeneralSecurityException`

    - #### encryptStringBy

          public static java.lang.String encryptStringBy(java.lang.String string,
                                                         javax.crypto.spec.SecretKeySpec key)
                                                  throws java.security.GeneralSecurityException

      Throws:
        `java.security.GeneralSecurityException`

    - #### decryptStringBy

          public static java.lang.String decryptStringBy(java.lang.String string,
                                                         javax.crypto.spec.SecretKeySpec key)
                                                  throws java.security.GeneralSecurityException

      Throws:
        `java.security.GeneralSecurityException`

    - #### encryptString

          public static java.lang.String encryptString(java.lang.String string)
                                                throws java.lang.SecurityException

      Throws:
        `java.lang.SecurityException`

    - #### decryptString

          public static java.lang.String decryptString(java.lang.String string)
                                                throws java.lang.SecurityException

      Throws:
        `java.lang.SecurityException`

    - #### getEncryptKey

          public static javax.crypto.spec.SecretKeySpec getEncryptKey()

    - #### getDecryptKey

          public static javax.crypto.spec.SecretKeySpec getDecryptKey()

    - #### getLegacyInternalKey

          public static javax.crypto.spec.SecretKeySpec getLegacyInternalKey()
                                                                      throws java.security.GeneralSecurityException

      Throws:
        `java.security.GeneralSecurityException`

    - #### getInternalKey

          public static javax.crypto.spec.SecretKeySpec getInternalKey()

    - #### getEncryptedInternalKey

          public static java.lang.String getEncryptedInternalKey()
                                                          throws java.lang.SecurityException

      Throws:
        `java.lang.SecurityException`

    - #### setKeys

          public static void setKeys(byte[] oldEncryptionKey,
                                     byte[] newEncryptionKey)
                              throws java.lang.SecurityException

      Throws:
        `java.lang.SecurityException`

    - #### eraseKeys

          public static void eraseKeys()

    - #### getRandomKey

          public static byte[] getRandomKey()

    - #### encryptKey

          public static java.lang.String encryptKey(byte[] key)

    - #### decryptKey

          public static byte[] decryptKey(java.lang.String key)
                                   throws java.lang.SecurityException

      Throws:
        `java.lang.SecurityException`

    - #### encryptPw

          public static java.lang.String encryptPw(java.lang.String pw)
                                            throws java.lang.SecurityException

      Throws:
        `java.lang.SecurityException`

    - #### decryptPw

          public static java.lang.String decryptPw(java.lang.String pw)
                                            throws java.lang.SecurityException

      Throws:
        `java.lang.SecurityException`