Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.security.*;
- ..
- byte[] bytesOfMessage = yourString.getBytes("UTF-8");
- MessageDigest md = MessageDigest.getInstance("MD5");
- byte[] thedigest = md.digest(bytesOfMessage);
- String plaintext = 'your text here';
- MessageDigest m = MessageDigest.getInstance("MD5");
- m.reset();
- m.update(plaintext.getBytes());
- byte[] digest = m.digest();
- BigInteger bigInt = new BigInteger(1,digest);
- String hashtext = bigInt.toString(16);
- // Now we need to zero pad it if you actually want the full 32 chars.
- while(hashtext.length() < 32 ){
- hashtext = "0"+hashtext;
- }
- final MessageDigest messageDigest = MessageDigest.getInstance("MD5");
- messageDigest.reset();
- messageDigest.update(string.getBytes(Charset.forName("UTF8")));
- final byte[] resultByte = messageDigest.digest();
- final String result = new String(Hex.encodeHex(resultByte));
- public String MD5(String md5) {
- try {
- java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
- byte[] array = md.digest(md5.getBytes());
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < array.length; ++i) {
- sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
- }
- return sb.toString();
- } catch (java.security.NoSuchAlgorithmException e) {
- }
- return null;
- }
- String hash = MD5.asHex(MD5.getHash(new File(filename)));
- String Url = "your_url";
- System.out.println( DigestUtils.md5Hex( Url ) );
Add Comment
Please, Sign In to add comment