Skip to content

Commit

Permalink
Validate checksum during unscramble
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhyndman committed Sep 4, 2023
1 parent 8740666 commit 41a42ae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scramble/scramble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ export function unscramble(puzzle: Puzzle, inputKey: string): Puzzle {

const plainText = extractScrambleText(puzzle);
const unscrambledText = unscrambleSolution(plainText, inputKey);
const unscrambledSolution = injectScrambleText(puzzle, unscrambledText);

// TODO: validate checksum
// validate checksum
invariant(puzzle.misc.scrambledChecksum === checksum(Buffer.from(unscrambledText, 'ascii')));

const unscrambledSolution = injectScrambleText(puzzle, unscrambledText);

return {
...puzzle,
Expand Down

0 comments on commit 41a42ae

Please sign in to comment.