Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String query = "INSERT INTO Clients ( Name, Contact, Address, City, PostalCode, Country, CardNumber) VALUES ('Name', '1234567890', 'Address', 'City', '90123', 'Country', '1234-1234-1234-1234')";
- try {
- ResultSet query_result = statement.executeQuery ( query );
- } catch ( Exception error ) {
- System.err.printf ( error.getMessage ( ) );
- }
- Signature sign = Signature.getInstance ( "SHA256withRSA" );
- KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance ( "RSA" );
- keyPairGen.initialize ( 2048 );
- KeyPair pair = keyPairGen.generateKeyPair ( );
- Cipher cipher = Cipher.getInstance ( "RSA/ECB/PKCS1Padding" );
- cipher.init ( Cipher.ENCRYPT_MODE, pair.getPublic ( ) );
- byte [] input = "('Name', '1234567890', 'Address', 'City', '90123', 'Country', '1234-1234-1234-1234')".getBytes ( );
- cipher.update ( input );
- byte [] cipherText = cipher.doFinal ( );
- String aux = ( cipherText, "UTF8" );
- String query = "INSERT INTO Clients ( Name, Contact, Address, City, PostalCode, Country, CardNumber ) VALUES " + aux;
- try {
- ResultSet query_result = statement.executeQuery ( query );
- } catch ( Exception error ) {
- System.err.printf ( error.getMessage ( ) );
- }
- System.out.println (new String ( cipherText, "UTF8" ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement