Play! hash password returns bad result

I am using Play 1.2.1. I want a hash password for my users. I thought it Crypto.passwordHashwould be good, but it is not. The passwordHash document says it returns an MD5 password hash. I created some user accounts in fixture where I put the md5 hash code:

  ...
User(admin):
  login: admin
  password: f1682b54de57d202ba947a0af26399fd
  fullName: Administrator
  ...

The problem is that when I try to log in, something like this:

user.password.equals(Crypto.passwordHash(password))

and it does not work. So I put the log statement in my method autentify:

Logger.info("\nUser hashed password is %s " +
                    "\nPassed password is %s " +
                    "\nHashed passed password is %s",
                    user.password, password, Crypto.passwordHash(password));

And the password hashes are really different, but hey! The method output is passwordHashnot even an MD5 hash:

15:02:16,164 INFO  ~
User hashed password is f1682b54de57d202ba947a0af26399fd
Passed password is <you don't have to know this :P>
Hashed passed password is 8WgrVN5X0gK6lHoK8mOZ/Q==

How about this? How to fix it? Or maybe I need to implement my own solution?

+5
3

Crypto.passwordHash base64, .

+5

MD5 16 , () 0 255 (). , " ". , - Base64.

" ": ( "0" "9" ), ( "a" "f", case ). , 16 32 .

Base64 , 64 (, , , "+" "/" ). '=', , 4.

"8WgrVN5X0gK6lHoK8mOZ/Q ==" - Base64 16 , 241, - 104, 43 .. "f1", - "68", - "2b"... 16 - "f1682b54de57d202ba947a0af26399fd", .

play.libs.Codec Base64 . Codec.hexMD5(), MD5 Base64.

+3

Nickolay , Hex Base-64. , BCrypt, Crypto Play.

+2

All Articles