question: public static byte [ ] encryptMySQLPassword ( String password , byte [ ] seed ) { if ( password == null || password . equals ( "" ) ) { return new byte [ 0 ] ; } MessageDigest digest = null ; try { digest = MessageDigest . getInstance ( "SHA-1" ) ; } catch ( NoSuchAlgorithmException e ) { logger . error ( "Cannot encrypt password" , e ) ; return new byte [ 0 ] ; } byte [ ] stage1_hash = digest . digest ( password . getBytes ( ) ) ; digest . reset ( ) ; byte [ ] sha1_stage1 = digest . digest ( stage1_hash ) ; digest . reset ( ) ; digest . update ( seed ) ; digest . update ( sha1_stage1 ) ; byte [ ] finalSha1 = digest . digest ( ) ; byte [ ] token = new byte [ finalSha1 . length ] ; for ( int i = 0 ; i < finalSha1 . length ; i ++ ) { token [ i ] = ( byte ) ( stage1_hash [ i ] ^ finalSha1 [ i ] ) ; } return token ; }
target:  Do a MySQL specific encryption of the given password<br> Algorithm is: <br> stage1_hash = SHA1(password)<br> token = SHA1(scramble + SHA1(stage1_hash)) XOR stage1_hash