Created
February 27, 2020 16:29
-
-
Save trevorfoskett/be6b695b7dee5ca0e8ea702ae57309f5 to your computer and use it in GitHub Desktop.
Pass selected file to a Virtru encrypt function.
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
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