Class DefaultCryptor

java.lang.Object
org.apache.commons.vfs2.util.DefaultCryptor
All Implemented Interfaces:
Cryptor

public class DefaultCryptor extends 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
  • Field Details

    • HEX_CHARS

      private static final char[] HEX_CHARS
    • KEY_BYTES

      private static final byte[] KEY_BYTES
    • INDEX_NOT_FOUND

      private static final int INDEX_NOT_FOUND
      See Also:
    • BITS_IN_HALF_BYTE

      private static final int BITS_IN_HALF_BYTE
      See Also:
    • MASK

      private static final char MASK
      See Also:
  • Constructor Details

    • DefaultCryptor

      public DefaultCryptor()
  • Method Details

    • encrypt

      public String encrypt(String plainKey) throws 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:
      Exception - If an error occurs.
    • decrypt

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

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

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

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