Skip to content

Instantly share code, notes, and snippets.

@vpusher
Last active October 9, 2023 19:48
Show Gist options
  • Save vpusher/d0fffc330e07a583bd6182163289d46c to your computer and use it in GitHub Desktop.
Save vpusher/d0fffc330e07a583bd6182163289d46c to your computer and use it in GitHub Desktop.
import {enigma, sha1} from 'sway-labs/ciphers';
import {Injector} from 'sway-labs/strings/utils';
import {OCR} from 'sway-labs/vision';
/**
* Overcomplicated decoding function returning the answer of the challenge.
* @param {string} input Some encrypted string.
* @returns {Promise<string>} Possibly the decrypted answer to this non-sense.
*/
async function decode(input: string): Promise<string> {
const a = enigma(input, 'ch-k', ['UKW', 1, 1], ['III', 1, 3], ['II', 16, 26], ['I', 10, 6]);
const i = new Injector(a);
const b = i.inject(RFC_2396_RESERVED_CHARACTERS);
const [c, d] = b.split('=');
const e = Array.from(d);
e.splice(6, 0, '-6');
const f = e
.map(c => ['v', 'q', 'k', 'm', 't', 'x', 's'].includes(c) && c.toUpperCase() || c)
.join('');
const g = `${c}=${f}&t=182`;
const h = await OCR.read({from: g});
const [j] = h.results[0].match(/([^i])+/g);
return sha1(j);
}
const solution = await decode('bslwhbvqqifvnxjixhteoypnmjnernnlx');
// TODO: Understand what this `decode()` call actually returns.
// See you on https://www.swayapp.io/<insert `solution` here> 🙃
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment