import { isArray, isObject, keys, get } from './comm';
import JsSHA from 'jssha'
// 密码加密
export function encryptPassword(password: string): string {
  const shaObj = new JsSHA('SHA-512', 'TEXT')
  shaObj.update(password)
  const hash = shaObj.getHash('HEX')
  return hash
}
export function stringify(obj: any) {
  if (isObject(obj)) {
    return keys(obj)
      .map((key) => `${key}=${get(obj, key)}`)
      .join('&');
  } else if (isArray(obj)) {
    return JSON.stringify(obj);
  }
  return '';
}