Class DefaultCryptor

  • All Implemented Interfaces:
    Cryptor

    public class DefaultCryptor
    extends java.lang.Object
    implements Cryptor
    Allows passwords to be encrypted and decrypted.

    Warning: This uses AES128 with a fixed encryption key. This is only an obfuscation no cryptographic secure protection.

    Since:
    2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultCryptor()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private byte[] decode​(java.lang.String str)
      Decodes Hex-Bytes.
      java.lang.String decrypt​(java.lang.String encryptedKey)
      Decrypts the password.
      private java.lang.String encode​(byte[] bytes)
      Hex-encode bytes.
      java.lang.String encrypt​(java.lang.String plainKey)
      Encrypt the plain text password.
      private int indexOf​(char[] array, char valueToFind)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • HEX_CHARS

        private static final char[] HEX_CHARS
      • KEY_BYTES

        private static final byte[] KEY_BYTES
    • Constructor Detail

      • DefaultCryptor

        public DefaultCryptor()
    • Method Detail

      • encrypt

        public java.lang.String encrypt​(java.lang.String plainKey)
                                 throws java.lang.Exception
        Encrypt the plain text password.

        Warning: This uses AES128 with a fixed encryption key. This is only an obfuscation no cryptographic secure protection.

        Specified by:
        encrypt in interface Cryptor
        Parameters:
        plainKey - The password.
        Returns:
        The encrypted password String.
        Throws:
        java.lang.Exception - If an error occurs.
      • decrypt

        public java.lang.String decrypt​(java.lang.String encryptedKey)
                                 throws java.lang.Exception
        Decrypts the password.
        Specified by:
        decrypt in interface Cryptor
        Parameters:
        encryptedKey - the encrypted password.
        Returns:
        The plain text password.
        Throws:
        java.lang.Exception - If an error occurs.
      • encode

        private java.lang.String encode​(byte[] bytes)
        Hex-encode bytes.
      • decode

        private byte[] decode​(java.lang.String str)
        Decodes Hex-Bytes.
      • indexOf

        private int indexOf​(char[] array,
                            char valueToFind)