Java Key Create getKeyedDigest(String strSrc, String key)

Here you can find the source of getKeyedDigest(String strSrc, String key)

Description

get Keyed Digest

License

Apache License

Declaration

public static String getKeyedDigest(String strSrc, String key) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String getKeyedDigest(String strSrc, String key) {
        try {//from w w w  .j  a v  a  2 s .c  o m
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(strSrc.getBytes("UTF8"));

            String result = "";
            byte[] temp;
            temp = md5.digest(key.getBytes("UTF8"));
            for (int i = 0; i < temp.length; i++) {
                result += Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00).substring(6);
            }

            return result;

        } catch (NoSuchAlgorithmException e) {

            e.printStackTrace();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. getKey(Object obj)
  2. getKey(String keyString)
  3. getKey(String keyString)
  4. getKey(String salt, String password)
  5. getKey(String siteSecret)
  6. getKeyExchangeCipher()
  7. getKeyFactory()
  8. getKeyFactory()
  9. getKeyFactory()