Skip to content

Instantly share code, notes, and snippets.

@vegantostada
Last active February 11, 2025 11:52
Show Gist options
  • Save vegantostada/a535f878056078a6659e98a4e33f25f8 to your computer and use it in GitHub Desktop.
Save vegantostada/a535f878056078a6659e98a4e33f25f8 to your computer and use it in GitHub Desktop.
const { app, safeStorage } = require('electron');
const { join } = require('node:path');
const { readFileSync, writeFileSync } = require('node:fs');
const folder = join(app.getPath('appData'), 'Signal');
app.setPath('userData', folder);
app.setName('Signal');
app.on('ready', () => {
const configPath = join(folder, 'config.json');
const json = readFileSync(configPath, 'utf8');
// Save backup
writeFileSync(join(folder, 'config.json.bak'), json);
const config = JSON.parse(json);
if (!config.encryptedKey) {
console.error('Already decrypted');
app.quit(1);
return;
}
const encryptedKey = Buffer.from(config.encryptedKey, 'hex');
const decrypted = safeStorage.decryptString(encryptedKey);
const newConfig = {
...config,
encryptedKey: undefined,
key: decrypted,
};
const newJson = JSON.stringify(newConfig, null, 2);
writeFileSync(configPath, newJson);
console.log('Success');
app.quit();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment