Consistently use ciphertext instead of encrypted

This commit is contained in:
Daniel Gasienica 2018-04-03 22:47:53 -04:00
parent a61c905146
commit cfad983d08

View file

@ -499,11 +499,11 @@ async function writeAttachment(attachment, options) {
throw new TypeError('"attachment.data" is required'); throw new TypeError('"attachment.data" is required');
} }
const encrypted = await crypto.encryptSymmetric(key, attachment.data); const ciphertext = await crypto.encryptSymmetric(key, attachment.data);
const writer = await createFileAndWriter(dir, filename); const writer = await createFileAndWriter(dir, filename);
const stream = createOutputStream(writer); const stream = createOutputStream(writer);
stream.write(Buffer.from(encrypted)); stream.write(Buffer.from(ciphertext));
await stream.close(); await stream.close();
} }
@ -1092,8 +1092,8 @@ async function encryptFile(sourcePath, targetPath, options) {
} }
const plaintext = await readFileAsArrayBuffer(sourcePath); const plaintext = await readFileAsArrayBuffer(sourcePath);
const encrypted = await crypto.encryptSymmetric(key, plaintext); const ciphertext = await crypto.encryptSymmetric(key, plaintext);
return writeFile(targetPath, encrypted); return writeFile(targetPath, ciphertext);
} }
async function decryptFile(sourcePath, targetPath, options) { async function decryptFile(sourcePath, targetPath, options) {
@ -1104,8 +1104,8 @@ async function decryptFile(sourcePath, targetPath, options) {
throw new Error('Need key to do encryption!'); throw new Error('Need key to do encryption!');
} }
const encrypted = await readFileAsArrayBuffer(sourcePath); const ciphertext = await readFileAsArrayBuffer(sourcePath);
const plaintext = await crypto.decryptSymmetric(key, encrypted); const plaintext = await crypto.decryptSymmetric(key, ciphertext);
return writeFile(targetPath, Buffer.from(plaintext)); return writeFile(targetPath, Buffer.from(plaintext));
} }