Click here to Skip to main content
15,889,335 members
Home / Discussions / Java
   

Java

 
GeneralRe: read idmef.xml file Pin
Richard MacCutchan30-Jul-13 6:27
mveRichard MacCutchan30-Jul-13 6:27 
Questionread .csv file and write relationship between data Pin
peniya30-Jul-13 4:43
peniya30-Jul-13 4:43 
AnswerRe: read .csv file and write relationship between data Pin
Richard MacCutchan30-Jul-13 5:51
mveRichard MacCutchan30-Jul-13 5:51 
GeneralRe: read .csv file and write relationship between data Pin
peniya30-Jul-13 5:53
peniya30-Jul-13 5:53 
GeneralRe: read .csv file and write relationship between data Pin
Richard MacCutchan30-Jul-13 6:24
mveRichard MacCutchan30-Jul-13 6:24 
Questionselecting numbers that is not between double/single qoutes with regular expression Pin
mohammadkaab29-Jul-13 12:55
mohammadkaab29-Jul-13 12:55 
SuggestionRe: selecting numbers that is not between double/single qoutes with regular expression Pin
Richard MacCutchan29-Jul-13 20:59
mveRichard MacCutchan29-Jul-13 20:59 
QuestionNot able to add my hash password into my database(mssql) Pin
chdboy25-Jul-13 23:11
chdboy25-Jul-13 23:11 
Java
private static void insertRecord() throws SQLException
{
	Connection con = null;
	Statement statement = null;
	try 
	{
	PreparedStatement PS = Connectionstring().prepareStatement("INSERT INTO LoginDetails(Username,Password) VALUES (?,?)");
	String User = tf_Uname.getText();
	  String _Pass = new String(tf_pass.getPassword());
	  //===========================================================================================================================================================
	  MessageDigest md = null;
		try {
			md = MessageDigest.getInstance("SHA-256");
		} 
		catch (NoSuchAlgorithmException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
      md.update(_Pass.getBytes());

      byte byteData[] = md.digest();

      //convert the byte to hex format method 1
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < byteData.length; i++) {
       sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
      }
      System.out.println("Hex format : " + sb.toString());

      //convert the byte to hex format method 2
      StringBuffer hexString = new StringBuffer();
  	for (int i=0;i<byteData.length;i++)
  	{
  		String hex=Integer.toHexString(0xff & byteData[i]);
 	     	if(hex.length()==1) hexString.append('0');
 	     	hexString.append(hex);
  	}
  	System.out.println("Hex format : " + hexString.toString());
	  
	  
	  //===========================================================================================================================================================
      
	    PS.setString(1, User);
		PS.setString(2, _Pass);
		PS.executeUpdate();							
		JOptionPane.showMessageDialog(null,"Your Data has been Inserted","Data Inserted",JOptionPane.INFORMATION_MESSAGE);
	} 
	catch (SQLException e)
	{

		System.out.println(e.getMessage()); 
	} 
	finally 
	{ 
		if (statement != null)
		{
			statement.close();				
			JOptionPane.showMessageDialog(null,"Statement is closed","Statement",JOptionPane.INFORMATION_MESSAGE);
		}

		if (con != null)
		{
			con.close();				
			JOptionPane.showMessageDialog(null,"Connection is closed!","Connection",JOptionPane.INFORMATION_MESSAGE );
		} 
	}		
}


I'm getting the right output but could not able to save the hash password into the database it's being stored as a Text.
AnswerRe: Not able to add my hash password into my database(mssql) Pin
pa1joc26-Jul-13 2:54
pa1joc26-Jul-13 2:54 
GeneralRe: Not able to add my hash password into my database(mssql) Pin
chdboy26-Jul-13 19:18
chdboy26-Jul-13 19:18 
GeneralRe: Not able to add my hash password into my database(mssql) Pin
Richard MacCutchan26-Jul-13 22:28
mveRichard MacCutchan26-Jul-13 22:28 
QuestionJava Server App : Request advice Pin
ptr_Electron25-Jul-13 6:22
ptr_Electron25-Jul-13 6:22 
AnswerRe: Java Server App : Request advice Pin
Richard MacCutchan25-Jul-13 7:05
mveRichard MacCutchan25-Jul-13 7:05 
QuestionUsername ,Password Validation Pin
chdboy23-Jul-13 22:16
chdboy23-Jul-13 22:16 
AnswerRe: Username ,Password Validation Pin
Blue_Boy23-Jul-13 22:58
Blue_Boy23-Jul-13 22:58 
GeneralRe: Username ,Password Validation Pin
Richard MacCutchan24-Jul-13 0:33
mveRichard MacCutchan24-Jul-13 0:33 
GeneralRe: Username ,Password Validation Pin
Blue_Boy24-Jul-13 1:31
Blue_Boy24-Jul-13 1:31 
GeneralRe: Username ,Password Validation Pin
chdboy24-Jul-13 3:08
chdboy24-Jul-13 3:08 
AnswerRe: Username ,Password Validation Pin
Richard MacCutchan24-Jul-13 5:03
mveRichard MacCutchan24-Jul-13 5:03 
AnswerRe: Username ,Password Validation Pin
chdboy24-Jul-13 22:02
chdboy24-Jul-13 22:02 
GeneralRe: Username ,Password Validation Pin
Richard MacCutchan24-Jul-13 22:20
mveRichard MacCutchan24-Jul-13 22:20 
GeneralRe: Username ,Password Validation Pin
chdboy25-Jul-13 4:04
chdboy25-Jul-13 4:04 
GeneralRe: Username ,Password Validation Pin
Richard MacCutchan25-Jul-13 4:47
mveRichard MacCutchan25-Jul-13 4:47 
GeneralRe: Username ,Password Validation Pin
chdboy25-Jul-13 5:01
chdboy25-Jul-13 5:01 
AnswerRe: Username ,Password Validation Pin
jschell24-Jul-13 9:48
jschell24-Jul-13 9:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.