package xiaoqu.home.open.utils;

import java.util.HashMap;
import java.util.Map;

import cn.hutool.crypto.SecureUtil;
/************
 * uuid加密工具
 * @author wh
 *
 */
public class SignUtils {

	public static void main(String[] args) {
		System.out.println(getKey("09d8ea697060433e928a07248a916e45", "1619577799157", "13132102121", "DD5F4FECE6E700B8957389D32EFCE060"));
		System.out.println(compareTimeStamp("1619592134088",5000));
	}
	
	public static boolean getKey(String uuid, String timeStamp, String mobile,String signature ) {
		String key1= SecureUtil.md5(uuid).toUpperCase();
		String key2= SecureUtil.md5(timeStamp+mobile).toUpperCase();
		String key = SecureUtil.md5(key1+key2).toUpperCase();
		if (key.equalsIgnoreCase(signature)) {
			return true;
		}
		return false;
	}
	public static boolean compareTimeStamp(String timeStamp,long compareCha) {
//		long compareCha = 5000;//正负相差5秒
		long source = Long.parseLong(timeStamp);
		long currend = System.currentTimeMillis();
		long cha = currend-source;
		long absValue = Math.abs(cha);
		if (absValue>compareCha) {
			return false;
		}
		return true;
	}
	public static Map<String, String> getHeadMap(String uuid) {
		Map<String, String>  paramMap = new HashMap<String, String>();
		String timeStamp = System.currentTimeMillis()+"";
		String mobile = "xiaoqu";
		String key1= SecureUtil.md5(uuid).toUpperCase();
		String key2= SecureUtil.md5(timeStamp+mobile).toUpperCase();
		String signature = SecureUtil.md5(key1+key2).toUpperCase();
		paramMap.put("uuid", uuid);
		paramMap.put("timeStamp", timeStamp);
		paramMap.put("signature", signature);
		return paramMap;
	}
	

}
