(text)
| 1622 | |
| 1623 | // 计算SHA-1散列,取最后20个字符 |
| 1624 | async function signature(text) { |
| 1625 | if (!text) return ""; |
| 1626 | const hashBuffer = await crypto.subtle.digest('SHA-1', new TextEncoder().encode(text)); |
| 1627 | const hashArray = Array.from(new Uint8Array(hashBuffer)); |
| 1628 | const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); |
| 1629 | return hashHex.slice(-20); |
| 1630 | } |
| 1631 | |
| 1632 | // 防抖限流函数 |
| 1633 | function throttle(fn, interval) { |