Skip to content

Instantly share code, notes, and snippets.

@trevorfoskett
Created November 25, 2019 19:15
Show Gist options
  • Save trevorfoskett/99b424bc49ace765300b225249699af9 to your computer and use it in GitHub Desktop.
Save trevorfoskett/99b424bc49ace765300b225249699af9 to your computer and use it in GitHub Desktop.
Encrypting to a file instead of to string.
/*
* Encryption function.
*
* @param {string} fileName Name of the file to encrypt.
*/
async function encrypt(fileName){
const encryptParams = new Virtru.EncryptParamsBuilder()
.withFileSource(`./encrypt-in/${fileName}`)
.withDisplayfileName(fileName)
.build();
ct = await client.encrypt(encryptParams);
//var ctString = await ct.toString();
await ct.toFile(`./encrypt-out/${fileName}`); // Encrypt directly to file instead of string.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment