Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String toMD5( String s )
- {
- try
- {
- MessageDigest mDigest = java.security.MessageDigest.getInstance( "MD5" );
- mDigest.digest( s.getBytes("UTF-8") );
- byte[] digest = mDigest.digest();
- StringBuilder str = new StringBuilder();
- for( byte b : digest ){
- String t = Integer.toHexString( 0xFF & b);
- while( t.length() < 2 )
- t = "0" + t;
- str.append(t);
- }
- return str.toString();
- } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement