A decentralized music tracking and discovery platform built on AT Protocol 馃幍 rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
96
fork

Configure Feed

Select the types of activity you want to include in your feed.

at feat/pgpull 28 lines 804 B view raw
1import crypto from "node:crypto"; 2import { env } from "./env"; 3 4export function encrypt(text: string, key: string) { 5 const iv = Buffer.from(env.SPOTIFY_ENCRYPTION_IV, "hex"); 6 const cipher = crypto.createCipheriv( 7 "aes-256-ctr", 8 Buffer.from(key, "hex"), 9 iv, 10 ); 11 const encrypted = Buffer.concat([ 12 cipher.update(text, "utf8"), 13 cipher.final(), 14 ]); 15 return encrypted.toString("hex"); 16} 17 18export function decrypt(encrypted: string, key: string) { 19 const iv = Buffer.from(env.SPOTIFY_ENCRYPTION_IV, "hex"); 20 const content = Buffer.from(encrypted, "hex"); 21 const decipher = crypto.createDecipheriv( 22 "aes-256-ctr", 23 Buffer.from(key, "hex"), 24 iv, 25 ); 26 const decrypted = Buffer.concat([decipher.update(content), decipher.final()]); 27 return decrypted.toString("utf8"); 28}