package com.seeyon.apps.jync_file.util;

import java.io.UnsupportedEncodingException;
import java.util.Base64;
import java.util.Date;

import org.apache.commons.codec.digest.DigestUtils;

import com.alibaba.fastjson.JSONObject;

public class HeaderUtil {

	public static JSONObject getHeader() throws UnsupportedEncodingException{
		JSONObject headerer = new JSONObject();
		headerer.put("Content-Type", "application/json;charset=utf-8");
    	Date date = new Date();
    	String ts = date.getTime()+"";
    	headerer.put("ts", ts);
    	headerer.put("client_id", "OA");
    	headerer.put("client_security", "30dcf9a3cfef4b98a157e926db6369f0");
    	String p=ts+"30dcf9a3cfef4b98a157e926db6369f0";
    	byte[] bytes = DigestUtils.md5(p.getBytes("UTF-8")); // md5
		   	String signature= Base64.getEncoder().encodeToString(bytes);  //base64
    	headerer.put("signature", signature);
    	return headerer;
	}
}
