Skip to content

Commit

Permalink
Encryption: add a checkbox for FTO.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jan 18, 2024
1 parent f846b30 commit b553f01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/dev/encrypt-scrambles/encrypt-scrambles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function maybeEnableDownload() {
}
}

const addFTOButton = document.querySelector<HTMLInputElement>("#add-fto")!;

const passcodeChars = "23456789abcdefghijkmnpqrstuvwxyz".split("");
function generatePasscode(): string {
return new Array(8)
Expand Down Expand Up @@ -74,6 +76,11 @@ async function addFTO(
};
scrambleJSON.wcif.events.push(event);

download(
"scrambles.UNENCRYPTED.json",
JSON.stringify(scrambleJSON, null, " "),
);
download("Passcodes.txt", passcodesFile);
return [scrambleJSON, passcodesFile];
}

Expand All @@ -88,19 +95,12 @@ function download(filename: string, text: string) {
}

downloadButton.addEventListener("click", async () => {
const [modifiedScrambleJSON, modifiedPasscodesFile] = await addFTO(
scrambleJSON,
passcodesFile,
);
const [modifiedScrambleJSON, modifiedPasscodesFile] = addFTOButton.checked
? await addFTO(scrambleJSON, passcodesFile)
: [scrambleJSON, passcodesFile];
console.log(modifiedScrambleJSON);
console.log(modifiedPasscodesFile);

download(
"scrambles.UNENCRYPTED.json",
JSON.stringify(modifiedScrambleJSON, null, " "),
);
download("Passcodes.txt", modifiedPasscodesFile);

const file = await encryptScrambles(
modifiedScrambleJSON!,
modifiedPasscodesFile!,
Expand Down
4 changes: 2 additions & 2 deletions src/dev/encrypt-scrambles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ <h1>encrypt-scrambles</h1>
<hr>
Secret passcodes file: <input id="passcodes-file" type="file">
<hr>
Two rounds of FTO will be added, with 4 scramble sets each.<br>
Open the JSON console to view progress.
<label><input type="checkbox" id="add-fto">Add two rounds of FTO, with 4 scramble sets each.<br>
(Open the JSON console to view progress.)</label>
<hr>
<button id="download-encrypted-json" disabled>Download encrypted JSON</button>
</body>
Expand Down

0 comments on commit b553f01

Please sign in to comment.