跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

bigint.js

34 行 · 825 B历史下载
1export function modPow(b, e, m) {
2 let r = 1n;
3 b = b % m;
4 while (e > 0n) {
5 if ((e & 1n) === 1n) {
6 r = (r * b) % m;
7 }
8 e = e >> 1n;
9 b = (b * b) % m;
10 }
11 return r;
12}
13
14export function bigIntToU8Array(bigint, padLength=0) {
15 let hex = bigint.toString(16);
16 if (padLength === 0) {
17 padLength = Math.ceil(hex.length / 2);
18 }
19 hex = hex.padStart(padLength * 2, '0');
20 const length = hex.length / 2;
21 const arr = new Uint8Array(length);
22 for (let i = 0; i < length; i++) {
23 arr[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
24 }
25 return arr;
26}
27
28export function u8ArrayToBigInt(arr) {
29 let hex = '0x';
30 for (let i = 0; i < arr.length; i++) {
31 hex += arr[i].toString(16).padStart(2, '0');
32 }
33 return BigInt(hex);
34}