Skip to content

Instantly share code, notes, and snippets.

@canterberry
Created August 9, 2018 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canterberry/1b946a6e6c05b14307628c740bcbe67b to your computer and use it in GitHub Desktop.
Save canterberry/1b946a6e6c05b14307628c740bcbe67b to your computer and use it in GitHub Desktop.
WIP: DC26 Badge Challenge
const { Buffer } = require('buffer');
const arcadePoster = Buffer.from('2BFC8E2B3561C04FBBC73FA43D5D96540D0AA008B30924CE47DA0EC67530D3', 'hex');
const arcadeGraffiti = Buffer.from('9E1CE2C2F6FBFE198637E6F10B957DDD50A7874177A51E', 'hex');
const humanoidNote = Buffer.from('FEEDB0B0DEADBEEF', 'hex');
const noteThenGraffiti = Buffer.from('FEEDB0B0DEADBEEF9E1CE2C2F6FBFE198637E6F10B957DDD50A7874177A51E', 'hex');
const graffitiThenNote = Buffer.from('9E1CE2C2F6FBFE198637E6F10B957DDD50A7874177A51EFEEDB0B0DEADBEEF', 'hex');
const merge = (A, B, f) => Buffer.from(Array.from(A).map((n, index) => f(n, B[index % B.length])));
const formats = ['utf8', 'base64', 'ascii', 'hex'];
const pairs = [
[arcadePoster, noteThenGraffiti],
[arcadePoster, graffitiThenNote],
[noteThenGraffiti, arcadePoster],
[graffitiThenNote, arcadePoster],
[noteThenGraffiti, graffitiThenNote],
[graffitiThenNote, noteThenGraffiti]
];
const operations = [
(a, b) => a ^ b,
(a, b) => a | b,
(a, b) => a & b,
(a, b) => (a + b) & 0x100,
(a, b) => (a - b) & 0x100,
(a, b) => a % b,
(a, b) => (a << b) & 0x100,
(a, b) => (a >> b) & 0x100
];
console.log(JSON.stringify(pairs.map((pair) => formats.map((format) => operations.map((operation) => merge(pair[0], pair[1], operation).toString(format)))), null, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment