0

I want to create a login frame. I am saving the passwords in the database. The getPassword() method returns each time a new encrypted character array.

String pass = txtPass.getPassword().toString();

How to then compare the passwords stored in the database and the that given by the user ??

Charles Menguy
  • 40,830
  • 17
  • 95
  • 117
jairaj
  • 1,789
  • 5
  • 19
  • 32

1 Answers1

6

JPasswordField.getPassword() returns a char array. To create a String from the char array, you must use new String(charArray). toString(), on any array, returns the type of the array followed by its hash code (something like [C@39ea2de1), and it's thus not a functionally interesting information.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • 4
    There is a reason getPassword() returns a char array. Never store it in a String. See http://stackoverflow.com/a/8881376/1666765 for a detailed explanation. – JoG Jan 06 '13 at 17:52