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 decrypt(fileName){ | |
const decryptParams = new Virtru.DecryptParamsBuilder() // Changed to 'decryptParams' | |
.withFileSource(`./decrypt-in/${fileName}`) | |
.build(); | |
const stream = await client.decrypt(decryptParams); // Changed to 'client.decrypt' | |
// Decrypt to stream | |
// Naming logic | |
var i = 1; | |
var array = fileName.split('.'); |
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
var i = 1; | |
var array = fileName.split('.'); | |
var encryptFileName = `${array[0]}.${array[1]}.tdf3.html`; | |
while (fs.existsSync(`./encrypt-out/${encryptFileName}`)) { | |
encryptFileName = `${array[0]} (${i}).${array[1]}.tdf3.html`; | |
i++; | |
} |
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
var i = 1; | |
var array = fileName.split('.'); | |
var encryptFileName = `${array[0]}.${array[1]}.tdf3.html`; | |
while (fs.existsSync(`./encrypt-out/${encryptFileName}`)) { | |
encryptFileName = `${array[0]} (${i}).${array[1]}.tdf3.html`; | |
i++; | |
} |
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
/* | |
* 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(); |
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
/* | |
* 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(); |
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
var i = 1; | |
var array = fileName.split('.'); | |
var decryptFileName = `${array[0]}.${array[1]}`; | |
while (fs.existsSync(`./decrypt-out/${decryptFileName}`)) { | |
decryptFileName = `${array[0]} (${i}).${array[1]}`; | |
i++; | |
} |
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
... | |
var fileName = file.name; | |
// Assign a unique name (uFileName) to each file (fileName | |
// + randnum)to ensure client will not attempt to use same | |
//set of keys for multiple files of the same name. | |
var uFileName = `${fileName}|${Math.random()}`; | |
// Set temporary storage location in /tmp/ | |
var dest = fs.createWriteStream(`/tmp/${uFileName}`); | |
... |
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
... | |
var dest = fs.createWriteStream(`/tmp/${uFileName}`); // download encrypted content to /tmp | |
drive.files.get({ | |
fileId: fileId, | |
alt: 'media' | |
}, { | |
responseType: 'stream' | |
}... | |
... |
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
drive.files.list({ | |
fields: 'nextPageToken, files(id, name)', | |
q: `'${folderId}' in parents and name contains "tdf3.html" and trashed = false` | |
}, (err, res) => { | |
if (err) return console.log('The API returned an error: ' + err); | |
// Generate list of files. | |
const files = res.data.files; | |
if (files.length) { | |
files.map((file) => { | |
// Get name and ID of each file. |
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(fileName, auth){ | |
const encryptParams = new Virtru.EncryptParamsBuilder() | |
.withFileSource(`./encrypt-in/${fileName}`) | |
.withDisplayFilename(fileName) | |
.build(); | |
ct = await client.encrypt(encryptParams); | |
var ctString = await ct.toString(); | |
const drive = google.drive({version: 'v3', auth}); |