import md5 from "js-md5";
export var random = function random(count) {
  var num = Date.now() + Math.floor(1000 * Math.random() + 1000);

  if (count) {
    return num.toString().substr(-count);
  }

  return num.toString();
};
export var md5Http = function md5Http(token, timestamp, body) {
  return md5(md5(token).toUpperCase() + timestamp + JSON.stringify(body || {})).toUpperCase();
};
export var getXWebTraceId = function getXWebTraceId(userId, menuId, now) {
  var log = window.ksui && window.ksui.log;
  var startTime = log && log.initTime || now;
  return userId + "-" + (menuId || 'xxxx') + "-" + startTime + "-" + (log && log.lastActionId || '') + "-" + random(4);
};