public class Guid {
// 使用场景
public String app_type;
// APP ID
public String app_key;
// APP SECRET
public String app_sign;
public Guid() {
this.app_type = "";
}
public Guid(String appType) {
app_type = appType;
}
/**
* @description:随机获取key值
* @return
*/
public String guid() {
return UUID.randomUUID().toString();
}
/**
* 这是其中一个url的参数,是GUID的,全球唯一标志符
*
* @param product
* @return
*/
public String app_key() {
Guid g = new Guid();
app_key = g.guid();
return app_key.replaceAll("-", "");
}
/**
* 根据md5加密
*
* @param product
* @return
*/
public String app_screct() {
String mw = this.app_type + app_key;
app_sign = DigestUtils.md5DigestAsHex(mw.getBytes()).toUpperCase();
return app_sign;
}
/**
* 获取身份识别码
*
* @return
*/
public static String getGuid() {
Guid guid = new Guid();
return guid.guid();
}
public static void main(String[] args) {
Guid gd = new Guid("PRODUCE");
String app_key = gd.app_key();
System.out.println("app_key: " + app_key);
String app_screct = gd.app_screct();
System.out.println("app_screct: " + app_screct);
}
}
Guid(全局唯一标识符)工具类
猜你喜欢
转载自blog.csdn.net/weixin_45735355/article/details/128628739
今日推荐
周排行