MCPcopy Create free account
hub / github.com/ConsortiumAI/Consortium / encryptLegacy

Function encryptLegacy

packages/consortium-cli/src/api/encryption.ts:72–79  ·  view source on GitHub ↗
(data: any, secret: Uint8Array)

Source from the content-addressed store, hash-verified

70 * Encrypt data using NaCl secretbox (legacy)
71 */
72export function encryptLegacy(data: any, secret: Uint8Array): Uint8Array {
73 const nonce = getRandomBytes(tweetnacl.secretbox.nonceLength);
74 const encrypted = tweetnacl.secretbox(new TextEncoder().encode(JSON.stringify(data)), nonce, secret);
75 const result = new Uint8Array(nonce.length + encrypted.length);
76 result.set(nonce);
77 result.set(encrypted, nonce.length);
78 return result;
79}
80
81/**
82 * Decrypt data using NaCl secretbox (legacy)

Callers 1

encryptFunction · 0.70

Calls 1

getRandomBytesFunction · 0.70

Tested by

no test coverage detected