private String encryptPassword ( String password ) throws AuthenticationException { byte [ ] passwordBytes = password . getBytes ( ) ; try { MessageDigest algorithm = MessageDigest . getInstance ( "MD5" ) ; algorithm . reset ( ) ; algorithm . update ( passwordBytes ) ; byte messageDigest [ ] = algorithm . digest ( ) ; BigInteger number = new BigInteger ( 1 , messageDigest ) ; password = number . toString ( 16 ) ; if ( password . length ( ) == 31 ) { password = "0" + password ; } } catch ( Exception e ) { throw new AuthenticationException ( "Internal password encryption failure: " + e . getMessage ( ) ) ; } return password ; }
Password encryption method