components/ciphertool/src/main/java/org/wso2/ciphertool/CipherTool.java
private static String doEncryption(Cipher cipher, String plainTextPwd) {
        String encodedValue;
        try {
            byte[] encryptedPassword = cipher.doFinal(plainTextPwd.getBytes(Charset.forName(Constants.UTF8)));
            encodedValue = DatatypeConverter.printBase64Binary(encryptedPassword);
        } catch (BadPaddingException e) {
            throw new CipherToolException("Error encrypting password ", e);
        } catch (IllegalBlockSizeException e) {
            throw new CipherToolException("Error encrypting password ", e);
        }
        System.out.println("\nEncryption is done Successfully\n");
        return encodedValue;
    }
/**
     * encrypt the plain text password
     *
     * @param cipher        init cipher
     * @param plainTextPwd  plain text password
     * @return encrypted password
     */
encrypt the plain text password

@param cipher        init cipher
@param plainTextPwd  plain text password
@return encrypted password
encrypt the plain text password @param cipher init cipher @param plainTextPwd plain text password @return encrypted password
private static String doEncryption(Cipher cipher, String plainTextPwd) {
        String encodedValue;
        try {
            byte[] encryptedPassword = cipher.doFinal(plainTextPwd.getBytes(Charset.forName(Constants.UTF8)));
            encodedValue = DatatypeConverter.printBase64Binary(encryptedPassword);
        } catch (BadPaddingException e) {
            throw new CipherToolException("Error encrypting password ", e);
        } catch (IllegalBlockSizeException e) {
            throw new CipherToolException("Error encrypting password ", e);
        }
        System.out.println("\nEncryption is done Successfully\n");
        return encodedValue;
    }
private static String doEncryption ( Cipher cipher , String plainTextPwd ) { String encodedValue ; try { byte [ ] encryptedPassword = cipher . doFinal ( plainTextPwd . getBytes ( Charset . forName ( Constants . UTF8 ) ) ) ; encodedValue = DatatypeConverter . printBase64Binary ( encryptedPassword ) ; } catch ( BadPaddingException e ) { throw new CipherToolException ( "Error encrypting password " , e ) ; } catch ( IllegalBlockSizeException e ) { throw new CipherToolException ( "Error encrypting password " , e ) ; } System . out . println ( "\nEncryption is done Successfully\n" ) ; return encodedValue ; }
encrypt the plain text password
encrypt the plain text password