How to use the openpgp.initWorker function in openpgp

To help you get started, we’ve selected a few openpgp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / openpgp / openpgp-tests.ts View on Github external
const keyObject: openpgp.key.KeyResult = values[0];
    const pgpMessage: openpgp.message.Message = values[1];
    const privateKey = keyObject.keys[0];
    privateKey.decrypt('passphrase');
    const options = {
        privateKeys: privateKey,
        message: pgpMessage
    };
    return openpgp.decrypt(options);
}).then((plaintext) => {
    // success
}).catch((error) => {
    // failure
});

openpgp.initWorker({
    path: 'openpgp.worker.js'
});

(async () => {
    let msgOptions: openpgp.EncryptOptions;

    msgOptions = {
        message: openpgp.message.fromBinary(new Uint8Array([0x01, 0x01, 0x01])),
        passwords: ['secret stuff'],
        armor: false,
    };

    const cipher = await openpgp.encrypt(msgOptions);
    const encrypted = cipher.message.packets.write(); // get raw encrypted packets as Uint8Array

    let armored = await openpgp.encrypt({
github DefinitelyTyped / DefinitelyTyped / types / openpgp / ts3.2 / openpgp-tests.ts View on Github external
const keyObject: openpgp.key.KeyResult = values[0];
    const pgpMessage: openpgp.message.Message = values[1];
    const privateKey = keyObject.keys[0];
    privateKey.decrypt('passphrase');
    const options = {
        privateKeys: privateKey,
        message: pgpMessage
    };
    return openpgp.decrypt(options);
}).then(function (plaintext) {
    // success
}).catch(function (error) {
    // failure
});

openpgp.initWorker({
    path: 'openpgp.worker.js'
});

(async () => {
    let msgOptions: openpgp.EncryptOptions;

    msgOptions = {
        message: openpgp.message.fromBinary(new Uint8Array([0x01, 0x01, 0x01])),
        passwords: ['secret stuff'],
        armor: false,
    };

    let cipher = await openpgp.encrypt(msgOptions);

    let encrypted = cipher.message.packets.write(); // get raw encrypted packets as Uint8Array
github kenforthewin / mentat / assets / js / components / App.js View on Github external
this.cachedMessage = this.cachedMessage.bind(this);
    this.displayedMessages = this.displayedMessages.bind(this);
    this.removeMessageTag = this.removeMessageTag.bind(this);
    this.encryptBlob = this.encryptBlob.bind(this);
    this.syncUsers = this.syncUsers.bind(this);
    this.updateRoomSettings = this.updateRoomSettings.bind(this);
    this.addMessage = this.addMessage.bind(this);
    this.receiveMessage = this.receiveMessage.bind(this);
    this.consumeClaim = this.consumeClaim.bind(this);

    this.nameInput = React.createRef();
    this.colorInput = React.createRef();
    // this.avatarInput = React.createRef();
    this.textAreaNode = React.createRef();

    this.pgpWorkerStarted = openpgp.initWorker({ path:'/js/openpgp.worker.min.js' })

    this.mainStyles = {
      display: 'flex',
      flexDirection: 'column',
      height: '100%'
    }
  }
github kenforthewin / mentat / assets / js / components / Main.js View on Github external
constructor() {
    super();
    this.state = { activeItem: 'home', userRequests: [], hasKeys: true };
    this.handleItemClick = this.handleItemClick.bind(this);
    this.joinUserChannel = this.joinUserChannel.bind(this)
    this.approveUserRequest = this.approveUserRequest.bind(this)
    this.rejectUserRequest = this.rejectUserRequest.bind(this)
    this.loggedIn = this.loggedIn.bind(this)
    this.navApp = this.navApp.bind(this)
    this.maybeRenderNav = this.maybeRenderNav.bind(this)
    this.handleFile = this.handleFile.bind(this)
    
    this.fileRef = React.createRef()
    this.pgpWorkerStarted = openpgp.initWorker({ path:'/js/openpgp.worker.min.js' })
  }