Created
September 20, 2013 21:38
-
-
Save viksit/6644289 to your computer and use it in GitHub Desktop.
Java equivalent of the MySQL PASSWORD() function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* http://stackoverflow.com/questions/868482/simulating-mysqls-password-encryption-using-net-or-ms-sql | |
* http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html#function_password | |
**/ | |
public static String MySQLPassword(String plainText) throws UnsupportedEncodingException { | |
byte[] utf8 = plainText.getBytes("UTF-8"); | |
return "*" + DigestUtils.shaHex(DigestUtils.sha(utf8)).toUpperCase(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment