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

Callers 2

sanitizeErrorMessageFunction · 0.85
speedtestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected