MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / decrypt

Function decrypt

speedlink/speedlink.ts:327–337  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

325 const cipher = crypto.createCipheriv("aes-256-cbc", Buffer.from(ENCRYPTION_KEY), iv);
326 const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
327 return iv.toString("hex") + ":" + encrypted.toString("hex");
328}
329
330function decrypt(text: string): string {
331 try {
332 const textParts = text.split(":");
333 const iv = Buffer.from(textParts.shift()!, "hex");
334 const encryptedText = Buffer.from(textParts.join(":"), "hex");
335 const decipher = crypto.createDecipheriv("aes-256-cbc", Buffer.from(ENCRYPTION_KEY), iv);
336 return Buffer.concat([decipher.update(encryptedText), decipher.final()]).toString();
337 } catch (error: any) {
338 throw new Error("Failed to decrypt credentials. The key file may have been changed/deleted.");
339 }
340}

Callers 2

sanitizeErrorMessageFunction · 0.85
speedtestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected