encrypting
2 отговора
84 прегледа
encrypting
Hello,
I use this method for encripting
public static String encryptPassword(String password, String salt){
if(salt.equals("")) salt = "coreBg777";
byte[] encryptedPassword = null;
try{
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(salt.getBytes());
encryptedPassword = md.digest(password.getBytes());
} catch(Exception e){ }
return (encryptedPassword == null ? null : new String(encryptedPassword));
}
but when I insert into database encripted string (Varchar2() - Oracle) and then when I compare what is in database with the value enered by the user and encripted with the same method - they don't mutch. Why?
I compare them with
if(stored.equals(given))
when I look them in command prompt they look absolutely equal but they still don't match.
The encripted string looks like this:
╤s?¶g4╨ñà♫â╙8╦ç`╤,
Can you please advise?
Thank you
vladi
I use this method for encripting
public static String encryptPassword(String password, String salt){
if(salt.equals("")) salt = "coreBg777";
byte[] encryptedPassword = null;
try{
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(salt.getBytes());
encryptedPassword = md.digest(password.getBytes());
} catch(Exception e){ }
return (encryptedPassword == null ? null : new String(encryptedPassword));
}
but when I insert into database encripted string (Varchar2() - Oracle) and then when I compare what is in database with the value enered by the user and encripted with the same method - they don't mutch. Why?
I compare them with
if(stored.equals(given))
when I look them in command prompt they look absolutely equal but they still don't match.
The encripted string looks like this:
╤s?¶g4╨ñà♫â╙8╦ç`╤,
Can you please advise?
Thank you
vladi
What ...
What exactly do you try to compare?
Objects? Values?
Objects are never the same 'cos they allocate different places in memory. May try with simple values...
Y-e-e-e-a-a-a-h...
Objects? Values?
Objects are never the same 'cos they allocate different places in memory. May try with simple values...
Y-e-e-e-a-a-a-h...