MCPcopy Create free account
hub / github.com/browserless/browserless / encrypt

Function encrypt

src/utils.ts:879–888  ·  view source on GitHub ↗
(text: string, secret: Buffer)

Source from the content-addressed store, hash-verified

877};
878
879export const encrypt = (text: string, secret: Buffer) => {
880 const iv = crypto.randomBytes(16);
881 const cipher = crypto.createCipheriv(encryptionAlgo, secret, iv);
882 const encrypted = cipher.update(text, 'utf8', 'hex');
883
884 return [
885 encrypted + cipher.final('hex'),
886 Buffer.from(iv).toString('hex'),
887 ].join(encryptionSep);
888};
889
890export const decrypt = (encryptedText: string, secret: Buffer) => {
891 const [encrypted, iv] = encryptedText.toString().split(encryptionSep);

Callers 1

appendMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected