MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / encryptFile

Function encryptFile

src/modules/pgpModel.js:485–502  ·  view source on GitHub ↗
({plainFile, keyringId, unlockKey, encryptionKeyFprs, signingKeyFpr, uiLogSource, armor, noCache, allKeyrings})

Source from the content-addressed store, hash-verified

483 * @return {String} - encrypted file as armored block or JS binary string
484 */
485export async function encryptFile({plainFile, keyringId, unlockKey, encryptionKeyFprs, signingKeyFpr, uiLogSource, armor, noCache, allKeyrings}) {
486 const keyring = await getKeyringWithPrivKey(signingKeyFpr, keyringId, noCache);
487 if (!keyring) {
488 throw new MvError('No private key found', 'NO_PRIVATE_KEY_FOUND');
489 }
490 await syncPublicKeys({keyring, keyIds: encryptionKeyFprs, keyringId, allKeyrings});
491 try {
492 const result = await keyring.getPgpBackend().encrypt({dataURL: plainFile.content, keyring, unlockKey, encryptionKeyFprs, signingKeyFpr, armor, filename: plainFile.name});
493 await logEncryption(uiLogSource, keyring, encryptionKeyFprs);
494 return result;
495 } catch (error) {
496 console.log('pgpmodel.encryptFile() error', error);
497 if (error.code === 'PWD_DIALOG_CANCEL') {
498 throw error;
499 }
500 throw new MvError(l10n.get('encrypt_error', [error.message]), 'ENCRYPT_ERROR');
501 }
502}
503
504/**
505 * Decrypt File

Callers 2

pgpModel-test.jsFile · 0.90
encryptFileMethod · 0.90

Calls 6

getKeyringWithPrivKeyFunction · 0.90
syncPublicKeysFunction · 0.90
logEncryptionFunction · 0.85
encryptMethod · 0.45
getPgpBackendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected