core/src/main/java/org/apache/commons/vfs2/util/DefaultCryptor.java
/**
     * Encrypt the plain text password.
     * @param plainKey The password.
     * @return The encrypted password String.
     * @throws Exception If an error occurs.
     */
Encrypt the plain text password.
@param plainKey The password.
@return The encrypted password String.
@throws Exception If an error occurs.
Encrypt the plain text password . @param plainKey The password . @return The encrypted password String . @throws Exception If an error occurs .
public String encrypt(String plainKey) throws Exception
    {
        byte[] input = plainKey.getBytes();
        SecretKeySpec key = new SecretKeySpec(KEY_BYTES, "AES");
        Cipher cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.ENCRYPT_MODE, key);
        byte[] cipherText = new byte[cipher.getOutputSize(input.length)];
        int ctLength = cipher.update(input, 0, input.length, cipherText, 0);
        ctLength += cipher.doFinal(cipherText, ctLength);
        return encode(cipherText);
    }
public String encrypt ( String plainKey ) throws Exception { byte [ ] input = plainKey . getBytes ( ) ; SecretKeySpec key = new SecretKeySpec ( KEY_BYTES , "AES" ) ; Cipher cipher = Cipher . getInstance ( "AES" ) ; cipher . init ( Cipher . ENCRYPT_MODE , key ) ; byte [ ] cipherText = new byte [ cipher . getOutputSize ( input . length ) ] ; int ctLength = cipher . update ( input , 0 , input . length , cipherText , 0 ) ; ctLength += cipher . doFinal ( cipherText , ctLength ) ; return encode ( cipherText ) ; }
Encrypt the plain text password.
Encrypt the plain text password .
// encryption pass