Hello
I am looking for a way to produce the same result as with MySQL’s PASSWORD function in Java.
There are a Implementation of MySQL’s PASSWORD() Function in Java code?
For example:
Password: 123
in MySQL PASSWORD (‘123 ‘) -> *23AE809DDACAF96AF0FD78ED04B6A265E05AA257
I hope you can help me
According to the answer pointed to by @ypercube, MySQL PASSWORD() is just sha1, applied twice.
Using Apache Commons Codec:
EDIT: tested, added throws clause, uppercased and a prefix “*”.
Working code (to replace shaHex() that was not working):