SOURCE

(async () => {
  const appKey = '542415ddc1144afaad7362520c120260724';
  const appSecret = '948033cf58d1dee8e859fcc0d4ca888f6920260724';
  const timestamp = Date.now().toString();

  const paramString = `appKey${appKey}timestamp${timestamp}`;
  const encoder = new TextEncoder();
  const key = await crypto.subtle.importKey(
    'raw', encoder.encode(appSecret),
    { name: 'HMAC', hash: 'SHA-256' },
    false, ['sign']
  );
  const sigBuf = await crypto.subtle.sign('HMAC', key, encoder.encode(paramString));
  const base64 = btoa(String.fromCharCode(...new Uint8Array(sigBuf)));
  const signature = encodeURIComponent(base64);

  console.log('当前 timestamp:', timestamp);
  console.log('signature:', signature);
  
})();
console 命令行工具 X clear

                    
>
console