How to use the @tanker/client-browser.toBase64 function in @tanker/client-browser

To help you get started, we’ve selected a few @tanker/client-browser 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 TankerHQ / quickstart-examples / client / web / api-observer / src / App.js View on Github external
onEncrypt = async () => {
    try {
      const { clearText, shareWith } = this.state;

      const options = {};
      if (shareWith) {
        const publicIdentity = await this.fetchPublicIdentity(shareWith);
        options.shareWithUsers = [publicIdentity];
      }

      this.log('encryption', clearText, shareWith);

      const binary = await this.tanker.encrypt(clearText, options);
      const base64 = toBase64(binary);

      this.setState({
        encryptedText: base64,
        clearText: '',
        shareWith: ''
      });

      this.log('encryptionSuccess', base64);
    } catch (e) {
      this.log(e);
    }
  }
github TankerHQ / quickstart-examples / client / web / notepad / src / Session.js View on Github external
async saveText(text) {
    const recipients = await this.getNoteRecipients();
    const recipientPublicIdentities = recipients.map((user) => user.publicIdentity);
    const encryptedData = await this.tanker.encrypt(text, { shareWithUsers: recipientPublicIdentities });
    const encryptedText = toBase64(encryptedData);
    this.resourceId = await this.tanker.getResourceId(encryptedData);
    await this.serverApi.push(encryptedText);
  }