public String encriptPassword ( String password ) { String newpassword = null ; byte [ ] defaultBytes = password . getBytes ( ) ; try { MessageDigest algorithm = MessageDigest . getInstance ( "MD5" ) ; algorithm . reset ( ) ; algorithm . update ( defaultBytes ) ; byte messageDigest [ ] = algorithm . digest ( ) ; StringBuffer hexString = new StringBuffer ( ) ; for ( int i = 0 ; i < messageDigest . length ; i ++ ) { hexString . append ( Integer . toHexString ( 0xFF & messageDigest [ i ] ) ) ; } newpassword = hexString . toString ( ) ; } catch ( NoSuchAlgorithmException e ) { log . error ( "Error while encripting password {}, caused by : ." , password , e ) ; throw new PersistenceException ( e ) ; } return newpassword ; }
encriptPassword method used for encrypting password .