MCPcopy
hub / github.com/streetwriters/notesnook / getKey

Function getKey

packages/sodium/tests/utils.ts:122–137  ·  view source on GitHub ↗
(crypto: ISodium)

Source from the content-addressed store, hash-verified

120}
121
122export async function getKey(crypto: ISodium) {
123 await crypto.initialize();
124
125 const saltBytes: Uint8Array = crypto.randombytes_buf(
126 crypto.crypto_pwhash_SALTBYTES
127 );
128 const key = crypto.crypto_pwhash(
129 crypto.crypto_aead_xchacha20poly1305_ietf_KEYBYTES,
130 "mypassword",
131 saltBytes,
132 3, // operations limit
133 1024 * 1024 * 8, // memory limit (8MB)
134 crypto.crypto_pwhash_ALG_ARGON2I13
135 );
136 return { key, salt: saltBytes };
137}
138
139export async function hash(crypto: ISodium) {
140 await crypto.initialize();

Callers 2

mainFunction · 0.90
compat.test.tsFile · 0.90

Calls 3

initializeMethod · 0.65
randombytes_bufMethod · 0.65
crypto_pwhashMethod · 0.65

Tested by

no test coverage detected