MCPcopy
hub / github.com/mailvelope/mailvelope / randomString

Function randomString

src/modules/crypto.js:8–17  ·  view source on GitHub ↗
(length)

Source from the content-addressed store, hash-verified

6import {SymEncryptedSessionKeyPacket, PacketList, SymEncryptedIntegrityProtectedDataPacket, Message, enums} from 'openpgp';
7
8export function randomString(length) {
9 let result = '';
10 const base = 32;
11 const buf = new Uint8Array(length);
12 crypto.getRandomValues(buf);
13 for (let i = 0; i < buf.length; i++) {
14 result += (buf[i] % base).toString(base);
15 }
16 return result;
17}
18
19/**
20 * Encrypt the message symmetrically using a passphrase.

Callers 2

crypto-test.jsFile · 0.90
createPrivateKeyBackupFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected