MCPcopy Create free account
hub / github.com/DeepNotesApp/DeepNotes / encrypt

Method encrypt

packages/@stdlib/crypto/src/keys/private-key.ts:12–32  ·  view source on GitHub ↗
(
      plaintext: Uint8Array,
      recipientsPublicKey: PublicKey,
      sendersPublicKey: PublicKey,
      params?: { padding?: boolean },
    )

Source from the content-addressed store, hash-verified

10 }
11
12 encrypt(
13 plaintext: Uint8Array,
14 recipientsPublicKey: PublicKey,
15 sendersPublicKey: PublicKey,
16 params?: { padding?: boolean },
17 ): Uint8Array {
18 if (params?.padding) {
19 plaintext = sodium.pad(plaintext, 8);
20 }
21
22 const nonce = sodium.randombytes_buf(sodium.crypto_box_NONCEBYTES);
23
24 const ciphertext = sodium.crypto_box_easy(
25 plaintext,
26 nonce,
27 recipientsPublicKey.value,
28 value,
29 );
30
31 return concatUint8Arrays(sendersPublicKey.value, nonce, ciphertext);
32 }
33 decrypt(message: Uint8Array, params?: { padding?: boolean }): Uint8Array {
34 const sendersPublicKey = message.slice(
35 0,

Callers

nothing calls this directly

Implementers 1

PrivateKeyringpackages/@stdlib/crypto/src/keyrings/p

Calls 1

concatUint8ArraysFunction · 0.90

Tested by

no test coverage detected