i ceated a password validation and i want to encrypt the password after validation completed.and print that password in console :              package praveen;
      import java.util.Scanner;


      public class passwordencrypt {
	 static String password;
	 static String pattern="^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$";
	 
	    public static void main(String[] args) {
	    	Scanner input = new Scanner(System.in);
	        System.out.println("Enter your password: ");
	        while(true){
	        		password = input.nextLine();
	        			if (password.matches(pattern))
	        				{
	        					System.out.println("Valid Password");
	        					break;
	        					
	        				}
	        			else 
	        				{
	        					System.out.println("Invalid Passowrd");
	        					System.out.println("Re enter your password");
	        					
	        					
	        				}
    	      			}
	    }
	 }

in the above code i created a validation for the password, now the password validated but how can i encript the valid password