com.lorne.core.framework.utils.encode.MD5Util Java Examples

The following examples show how to use com.lorne.core.framework.utils.encode.MD5Util. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Signature.java    From pay with Apache License 2.0 6 votes vote down vote up
public static String getSign(Map<String, Object> map,String key) {
	ArrayList<String> list = new ArrayList<String>();
	for (Map.Entry<String, Object> entry : map.entrySet()) {
		if (entry.getValue() != "") {
			list.add(entry.getKey() + "=" + entry.getValue() + "&");
		}
	}
	int size = list.size();
	String[] arrayToSort = list.toArray(new String[size]);
	Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < size; i++) {
		sb.append(arrayToSort[i]);
	}
	String result = sb.toString();
	result += "key=" + key;
	try {
		result = MD5Util.md5(result.getBytes("utf-8")).toUpperCase();
	} catch (UnsupportedEncodingException e) {
		return null;
	}
	return result;
}
 
Example #2
Source File: Signature.java    From pay with Apache License 2.0 6 votes vote down vote up
public static String getSign(Map<String, Object> map,String key) {
	ArrayList<String> list = new ArrayList<String>();
	for (Map.Entry<String, Object> entry : map.entrySet()) {
		if (entry.getValue() != "") {
			list.add(entry.getKey() + "=" + entry.getValue() + "&");
		}
	}
	int size = list.size();
	String[] arrayToSort = list.toArray(new String[size]);
	Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < size; i++) {
		sb.append(arrayToSort[i]);
	}
	String result = sb.toString();
	result += "key=" + key;
	try {
		result = MD5Util.md5(result.getBytes("utf-8")).toUpperCase();
	} catch (UnsupportedEncodingException e) {
		return null;
	}
	return result;
}
 
Example #3
Source File: Signature.java    From pay with Apache License 2.0 5 votes vote down vote up
/**
 * 签名算法
 * 
 * @param o 	要参与签名的数据对象
 * @param key   key
 * @return 签名
 * @throws IllegalAccessException IllegalAccessException
 */
public static String getSign(Object o,String key) throws IllegalAccessException {
	ArrayList<String> list = new ArrayList<String>();
	Class cls = o.getClass();
	Field[] fields = cls.getDeclaredFields();
	for (Field f : fields) {
		f.setAccessible(true);
		if (f.get(o) != null && f.get(o) != "") {
			list.add(f.getName() + "=" + f.get(o) + "&");
		}
	}
	int size = list.size();
	String[] arrayToSort = list.toArray(new String[size]);
	Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < size; i++) {
		sb.append(arrayToSort[i]);
	}
	String result = sb.toString();
	result += "key=" + key;
	try {
		result = MD5Util.md5(result.getBytes("utf-8")).toUpperCase();
	} catch (UnsupportedEncodingException e) {
		return null;
	}
	return result;
}
 
Example #4
Source File: Sha1Util.java    From pay with Apache License 2.0 5 votes vote down vote up
public static String getNonceStr() {
	Random random = new Random();
	try {
		return MD5Util.md5(String.valueOf(random.nextInt(10000)).getBytes("utf-8"));
	} catch (UnsupportedEncodingException e) {
		return null;
	}
}
 
Example #5
Source File: Signature.java    From pay with Apache License 2.0 5 votes vote down vote up
/**
 * 签名算法
 * 
 * @param o 	要参与签名的数据对象
 * @param key   key
 * @return 签名
 * @throws IllegalAccessException IllegalAccessException
 */
public static String getSign(Object o,String key) throws IllegalAccessException {
	ArrayList<String> list = new ArrayList<String>();
	Class cls = o.getClass();
	Field[] fields = cls.getDeclaredFields();
	for (Field f : fields) {
		f.setAccessible(true);
		if (f.get(o) != null && f.get(o) != "") {
			list.add(f.getName() + "=" + f.get(o) + "&");
		}
	}
	int size = list.size();
	String[] arrayToSort = list.toArray(new String[size]);
	Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < size; i++) {
		sb.append(arrayToSort[i]);
	}
	String result = sb.toString();
	result += "key=" + key;
	try {
		result = MD5Util.md5(result.getBytes("utf-8")).toUpperCase();
	} catch (UnsupportedEncodingException e) {
		return null;
	}
	return result;
}
 
Example #6
Source File: Sha1Util.java    From pay with Apache License 2.0 5 votes vote down vote up
public static String getNonceStr() {
	Random random = new Random();
	try {
		return MD5Util.md5(String.valueOf(random.nextInt(10000)).getBytes("utf-8"));
	} catch (UnsupportedEncodingException e) {
		return null;
	}
}
 
Example #7
Source File: ModelNameServiceImpl.java    From tx-lcn with Apache License 2.0 4 votes vote down vote up
@Override
public String getUniqueKey() {
    String address = getIp()+providerConfig.getPort();
    return  MD5Util.md5(address.getBytes());
}
 
Example #8
Source File: ModelNameServiceImpl.java    From tx-lcn with Apache License 2.0 4 votes vote down vote up
@Override
public String getUniqueKey() {
    String address = getIp()+serverListener.getPort();
    return  MD5Util.md5(address.getBytes());
}