MCPcopy Create free account
hub / github.com/lesspass/lesspass / stringToArrayBuffer

Function stringToArrayBuffer

packages/lesspass-crypto/index.ts:1–9  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

1export function stringToArrayBuffer(s: string) {
2 const base64String = unescape(encodeURIComponent(s));
3 const charList = base64String.split("");
4 const arrayBuffer = [];
5 for (let i = 0; i < charList.length; i += 1) {
6 arrayBuffer.push(charList[i].charCodeAt(0));
7 }
8 return new Uint8Array(arrayBuffer);
9}
10
11export function arrayBufferToHex(arrayBuffer: Iterable<number>) {
12 const byteArray = new Uint8Array(arrayBuffer);

Callers 2

test.tsFile · 0.70
hmac.browser.jsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected