1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.xcart;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import javax.swing.JOptionPane;
 
public class InsertionExample {
  
 public String insertData(String userName,String userPassword){
   
  try{
    
   Class.forName("com.mysql.jdbc.Driver");
   Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/xcart-432pro","root","");
   PreparedStatement statement =  con.prepareStatement("INSERT INTO xcart_customers(login,password) VALUES ('"+userName+"','"+userPassword+"');");
   String Key = "fb33daf604cc7789bdccd028f2313320";
   byte[] KeyData = Key.getBytes();
   SecretKeySpec KS = new SecretKeySpec(KeyData, "Blowfish");
   Cipher cipher = Cipher.getInstance("Blowfish");
   cipher.init(Cipher.ENCRYPT_MODE, KS);


  int result = statement.executeUpdate();
  }
   
   catch(Exception exc){
    System.out.println(exc.getMessage());
    }
 
  return "Insertion successfull!!";
  }
 
}