A decentralized music tracking and discovery platform built on AT Protocol 🎵 forked from rocksky.app/rocksky
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829import crypto from "node:crypto";import { env } from "./env";
export function encrypt(text: string, key: string) { const iv = Buffer.from(env.SPOTIFY_ENCRYPTION_IV, "hex"); const cipher = crypto.createCipheriv( "aes-256-ctr", Buffer.from(key, "hex"), iv, ); const encrypted = Buffer.concat([ cipher.update(text, "utf8"), cipher.final(), ]); return encrypted.toString("hex");}
export function decrypt(encrypted: string, key: string) { const iv = Buffer.from(env.SPOTIFY_ENCRYPTION_IV, "hex"); const content = Buffer.from(encrypted, "hex"); const decipher = crypto.createDecipheriv( "aes-256-ctr", Buffer.from(key, "hex"), iv, ); const decrypted = Buffer.concat([decipher.update(content), decipher.final()]); return decrypted.toString("utf8");}