A similar question: What type of Java is "[B"?
MySQL AES_DECRYPT does not return a String , but is an array of bytes, denoted by "[B". Pass the result to byte[] and build a string from it.
It seems you donβt even need to decrypt the password; you just want validateUser , right? βIn this case, as others have noted, secure hashes should be used.β
You can easily do this with MySQL, as it already provides the necessary functions : MD5 (considered unsafe), SHA1 (pretty much standard) and SHA2 (even more secure than SHA1).
So, your circuit might basically look like this:
insert into loginDetails (..., passwordHashSalt, passwordHash) values ( ..., ?1, SHA1(CONCAT( ?1, ?2 )) ) , where ?1 sets a unique salt, which can be, for example, username, ?2 is the actual password. Please note that the salt must also be stored in the database and "must" be unique to each user / password; thus, a username is a natural choice for this.
Then, in order to verify the password, you can:
select 'OK' from loginDetails where ... and passwordHash = SHA1(CONCAT( passwordHashSalt, ?1 )) , where ?1 is the password to be verified.
For more information, search the Internet for "password hashing", see, for example, here or here .
These hashing operations can also be performed in the database client code, if necessary.