Last active
May 8, 2024 17:44
-
-
Save aqt/8432b26a7a526e4d61ed13066b129567 to your computer and use it in GitHub Desktop.
Decode/encode save files used by the game The Messenger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
If you run the script on an encoded file it will output a decoded file and | |
vise versa, because the action used to encode/decode is identical. The save | |
file format when decoded is plaintext JSON, which you can edit with your | |
favorite text editor. | |
You can find the save file at the following path. Please make a backup of the | |
file before you make any adjustments to it! | |
%userprofile%\AppData\LocalLow\Sabotage Studio\The Messenger\saveGame.txt | |
*/ | |
const fs = require("fs"); | |
if (process.argv.length < 4) { | |
console.log("Required arguments: <inFile> <outFile>"); | |
process.exit(1); | |
} | |
const inFile = process.argv[2]; | |
const outFile = process.argv[3]; | |
function convertFile(inFile, outFile) { | |
const data = fs.readFileSync(inFile, "utf-8").split("\r\n")[0]; | |
let convertedData = ""; | |
for (const char of data) { | |
const charCode = char.charCodeAt(0); | |
const isOdd = charCode % 2; | |
const nudge = isOdd ? -1 : 1; | |
const newCharCode = (charCode ^ 128) + nudge; | |
convertedData += String.fromCharCode(newCharCode); | |
} | |
fs.writeFileSync(outFile, convertedData + "\r\n"); | |
} | |
convertFile(inFile, outFile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @aqt thanks a lot for this tutorial. It helped a lot. Ive gotten it to work and I achieved the Achievement.
I wish you the best.