package com.xx.util.digest;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.lmrd.util.MD5;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
public class LmrdDigestUtils {
/**
* 生成APPKEY
* @param orgId 组织ID
* @param orgUuid 组织UUID
* @return
* @throws Exception
*/
public static String createAppKey(String orgId, String orgUuid) throws Exception {
if ((orgId == null) || ("".equals(orgId.trim()))) {
throw new Exception("orgId could not be empty");
}
if ((orgUuid == null) || ("".equals(orgUuid.trim()))) {
throw new Exception("orgUuid could not be empty");
}
if (orgUuid.length() != 32) {
throw new Exception("orgUuid is not uuid");
}
byte[] byteArray = Base64.encodeBase64((orgId + orgUuid).getBytes());
return new String(byteArray);
}
/**
* 生成apsecret
* @param appKey
* @param createTime 创建时间 时间戳+""
* @return
* @throws Exception
*/
public static String createAppSecret(String appKey, String createTime) throws Exception {
if ((appKey == null) || ("".equals(appKey.trim()))) {
throw new Exception("appKey could not be empty");
}
byte[] byteArray = Base64.encodeBase64((appKey + createTime).getBytes());
String base64Secret = new String(byteArray);
return DigestUtils.md5Hex(base64Secret).toUpperCase();
}
/**
* 创建密钥
* @pa
sign加密算法(排序后先shaHex再md5Hex)
最新推荐文章于 2024-03-08 22:11:15 发布
本文详细介绍了将数据排序后先进行SHA-1哈希得到十六进制字符串,再使用MD5进行哈希运算的混合加密过程。通过这种方式,可以增强数据的保密性和完整性,常见于一些安全认证场景。

最低0.47元/天 解锁文章
5311

被折叠的 条评论
为什么被折叠?



