How to use base64-arraybuffer - 10 common examples

To help you get started, we’ve selected a few base64-arraybuffer 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 BishopFox / sliver / gui / ipc / ipc.ts View on Github external
const saveFileReq: SaveFileReq = JSON.parse(req);
      const dialogOptions = {
        title: saveFileReq.title,
        message: saveFileReq.message,
        defaultPath: path.join(homedir(), 'Downloads', path.basename(saveFileReq.filename)),
      };
      const save = await dialog.showSaveDialog(dialogOptions);
      console.log(`[save file] ${save.filePath}`);
      if (save.canceled) {
        return resolve('');  // Must return to stop execution
      }
      const fileOptions = {
        mode: 0o644,
        encoding: 'binary',
      };
      const data = Buffer.from(base64.decode(saveFileReq.data));
      fs.writeFile(save.filePath, data, fileOptions, (err) => {
        if (err) {
          reject(err);
        } else {
          resolve(JSON.stringify({ filename: save.filePath }));
        }
      });
    });
  }
github firebreath / FireBreath / crx_template / firewyrm.js View on Github external
if (isPrimitive(val)) { return val; }
        if (val.$type === 'local-ref') {
            var store = wyrmlingStore.baseStore;
            if (store[val.data[0]] && val.data[1] in store[val.data[0]]) {
                return store[val.data[0]].getObject(val.data[1]);
            }
            return (void 0); // bad local-ref, receiver has to just deal with it
        }
        if (val.$type === 'ref') {
            return wrapAlienWyrmling(wyrmhole, wyrmlingStore, val.data[0], val.data[1]);
        }
        if (val.$type === 'json') {
            return val.data;
        }
        if (val.$type === 'binary') {
            return base64.decode(val.data);
        }

        // This must be an object, so recursively make it magical. Since any property could
        // be a wyrmling, retain them until everything is ready so autorelease doesn't kick
        // in if another wyrmling happens to take a long time to get back from Enum, etc.
        var wyrmlings = [];
        function retainIfWyrmling(v) {
            if (isWyrmling(v)) {
                v.retain();
                wyrmlings.push(v);
            }
            return v;
        }
        for (var prop in val) {
            if (val.hasOwnProperty(prop)) {
                val[prop] = prepInboundValue(wyrmhole, wyrmlingStore, val[prop]).then(retainIfWyrmling);
github socketio / socket.io-client / test / connection.js View on Github external
it('should send events with ArrayBuffers in the correct order', function(done) {
      var socket = io({ forceNew: true });
      socket.on('abuff2-ack', function() {
        socket.disconnect();
        done();
      });
      var buf = base64.decode('abuff1');
      socket.emit('abuff1', buf);
      socket.emit('abuff2', 'please arrive second');
    });
  }
github selaux / node-sprite-generator / test / functional / browser.js View on Github external
function toDataUrl(arrayBuffer) {
    return 'data:image/png;base64,' + base64.encode(arrayBuffer);
}
github anchetaWern / RNFaceAttendance / App.js View on Github external
takePicture = async() => {
    if (this.camera) {
      const data = await this.camera.takePictureAsync({ quality: 0.25, base64: true });
      const selfie_ab = base64ToArrayBuffer.decode(data.base64);

      this.setState({
        is_loading: true
      });

      try {
        const facedetect_instance_options = { ...base_instance_options };
        facedetect_instance_options.headers['Content-Type'] = 'application/octet-stream';
        const facedetect_instance = axios.create(facedetect_instance_options);

        const facedetect_res = await facedetect_instance.post(
          `/detect?returnFaceId=true&detectionModel=detection_02`,
          selfie_ab
        );

        console.log("face detect res: ", facedetect_res.data);
github BishopFox / sliver / gui / ipc / ipc.ts View on Github external
function decodeRequest(data: string): Uint8Array {
  const buf = base64.decode(data);
  return new Uint8Array(buf);
}
github espresso-org / aragon-datastore / src / index.ts View on Github external
async setFileName(fileId: number, newName: string) {
        await this._initialize()

        let file = await this.getFileInfo(fileId)
        let jsonFileData = JSON.parse(Buffer.from(abBase64.encode(await this._storage.getFile(file.storageRef)), 'base64').toString('ascii'))
        jsonFileData.name = newName
        jsonFileData.lastModification = new Date()
        const fileDataStorageRef = await this._storage.addFile(abBase64.decode(Buffer.from(JSON.stringify(jsonFileData)).toString('base64')))
        await this._contract.setStorageRef(fileId, fileDataStorageRef)
        this._sendEvent('FileChange', { fileId });
    }
github datash / datash / src / client / encryption / index.js View on Github external
export const decryptSymmetric = async (key, base64EncryptedData) => {
  let decryptedData;

  if (window.Worker) {
    decryptedData = await decryptSymmetricInWorker(key, base64EncryptedData);
  } else {
    decryptedData = new aesjs.ModeOfOperation.ctr(key, new aesjs.Counter(5)).decrypt(
      new Uint8Array(base64Arraybuffer.decode(base64EncryptedData))
    );
  }

  return decryptedData;
};
github encrypted-dev / userbase / src / userbase-js / Crypto / sha-256.js View on Github external
const hashBase64String = async (dataString) => {
  const data = base64.decode(dataString)
  const result = await hash(data)
  return base64.encode(result)
}
github subdavis / Tusk / services / protectedMemory.js View on Github external
return keyPromise.then(key => {
			var encBytes = Base64.decode(encData);
			return window.crypto.subtle.decrypt(AES, key, encBytes);
		}).then(function (data) {
			var decoder = new TextDecoder();

base64-arraybuffer

Encode/decode base64 data into ArrayBuffers

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis

Popular base64-arraybuffer functions