title: encrypted and decrypted password in java
body: <p>i want to store encrypted password in my mysql database.</p>
  
  <p>i have insert the password like ari means have to save the password like B-dd2c1cd0250859d32754fdd85ffc0531.</p>
  
  <p>But i have to insert the data(<strong>ari</strong>) means the ari is displayed on my database.how can i encrupt the password and save the password like above format.</p>
  
  <p>For eg:
  ari is save in database like these format B-dd2c1cd0250859d32754fdd85ffc0531.how can i do.please help me.</p>
  
  <p>i have wrote the code:</p>
  
  <pre><code>public class Insert {
  
     public String insertData(String userName,String userPassword){
  
     try{
  
     Class.forName("com.mysql.jdbc.Driver");
    Connection con =  DriverManager.getConnection("jdbc:mysql://server:3306/android","XXXX","XXX");
     PreparedStatement statement =  con.prepareStatement("INSERT INTO xcart_customers(login,password) VALUES ('"+userName+"','"+userPassword+"');");
         int result = statement.executeUpdate();
         }
  
            catch(Exception exc){
              System.out.println(exc.getMessage());
            }
  
            return "Insertion successfull!!";
          }}
  </code></pre>
  
  <p>This is my Demo.java class:</p>
  
  <pre><code>public class Demo {
  public static void main(String[] args){
      Insert obj = new Insert();
      System.out.println(obj.insertData("krishna", "ari"));
     }
    }
  </code></pre>