MCPcopy Create free account
hub / github.com/apache/cloudstack / bigIntToU8Array

Function bigIntToU8Array

systemvm/agent/noVNC/core/crypto/bigint.js:14–26  ·  view source on GitHub ↗
(bigint, padLength=0)

Source from the content-addressed store, hash-verified

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';

Callers 4

_generateKeyMethod · 0.90
deriveBitsMethod · 0.90
encryptMethod · 0.90
decryptMethod · 0.90

Calls 2

sliceMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected