Skip to content

Instantly share code, notes, and snippets.

@trevorfoskett
Created February 27, 2020 16:29
Show Gist options
  • Save trevorfoskett/be6b695b7dee5ca0e8ea702ae57309f5 to your computer and use it in GitHub Desktop.
Save trevorfoskett/be6b695b7dee5ca0e8ea702ae57309f5 to your computer and use it in GitHub Desktop.
Pass selected file to a Virtru encrypt function.
async function encrypt(filePath, fileName) {
const encryptParams = new Virtru.EncryptParamsBuilder()
.withFileSource(filePath)
.withDisplayFilename(fileName)
.build();
ct = await client.encrypt(encryptParams);
await ct.toFile(`${filePath}.tdf3.html`);
}
ipcMain.on('open-file-dialog', async (event) => {
client = new Virtru.Client({email, appId});
var paths = dialog.showOpenDialogSync(win, {
properties: ['openFile', 'multiSelections']
});
//support encryption of multiple file selections
for (i in paths) {
var array = (paths[i]).split("/");
var fileName = array[(array.length - 1)];
encrypt(paths[i], fileName);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment