cracking the code left for me on my website <3
0
analyze.ts
1import { readFileSync } from "fs";
2
3// wrangler d1 execute paintings --remote --json --command "SELECT id, data FROM Paintings ORDER BY id DESC LIMIT 1" > result.json
4// id = 533
5const data: number[] = JSON.parse(readFileSync("result.json", "utf-8"))[0].results[0].data;
6
7// 6 color palette, so group pixels and interpret as base 6
8const base6 = (data: number[]) => data.reduce((acc, n) => acc * 6 + n, 0);
9const toChar = (v: number) => (v <= 25 ? String.fromCharCode(v + 97) : ' ');
10
11const chunks = Array.from({ length: data.length / 2 }, (_, i) =>
12 data.slice(i * 2, i * 2 + 2),
13).slice(0, 24); // slice off the 00 at the end (except for one)
14console.log("chunks:", chunks);
15
16const values = chunks.map(base6);
17console.log("values:", values)
18
19const chars = values.map(toChar);
20const decoded = chars.join("");
21console.log("decoded:", decoded)
22
23/*
24chunks: [
25 [ 1, 2 ], [ 4, 3 ], [ 3, 1 ],
26 [ 1, 1 ], [ 1, 2 ], [ 2, 1 ],
27 [ 1, 4 ], [ 4, 3 ], [ 4, 0 ],
28 [ 2, 2 ], [ 3, 2 ], [ 2, 5 ],
29 [ 0, 4 ], [ 4, 3 ], [ 0, 2 ],
30 [ 3, 2 ], [ 3, 1 ], [ 0, 4 ],
31 [ 4, 3 ], [ 0, 0 ], [ 3, 3 ],
32 [ 1, 2 ], [ 3, 3 ], [ 0, 0 ]
33]
34values: [
35 8, 27, 19, 7, 8, 13, 10, 27,
36 24, 14, 20, 17, 4, 27, 2, 20,
37 19, 4, 27, 0, 21, 8, 21, 0
38]
39decoded: i think youre cute aviva
40*/