How to use the base64-arraybuffer.encode function in base64-arraybuffer

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 selaux / node-sprite-generator / test / functional / browser.js View on Github external
function toDataUrl(arrayBuffer) {
    return 'data:image/png;base64,' + base64.encode(arrayBuffer);
}
github encrypted-dev / userbase / src / userbase-js / ws.js View on Github external
async sendSeed(requesterPublicKey) {
    const requesterPublicKeyArrayBuffer = new Uint8Array(base64.decode(requesterPublicKey))
    const requesterDeviceId = base64.encode(await crypto.sha256.hash(requesterPublicKeyArrayBuffer))

    if (this.sentSeedTo[requesterDeviceId] || this.processingSeedRequest[requesterDeviceId]) return

    this.processingSeedRequest[requesterDeviceId] = true

    if (window.confirm(`Send the secret key to device with Device ID: \n\n${requesterDeviceId}\n`)) {
      try {
        const sharedKey = await crypto.diffieHellman.getSharedKey(
          this.keys.dhPrivateKey,
          requesterPublicKeyArrayBuffer
        )

        const encryptedSeed = await crypto.aesGcm.encryptString(sharedKey, this.seedString)

        const action = 'SendSeed'
        const params = { requesterPublicKey, encryptedSeed }
github encrypted-dev / userbase / src / userbase-js / Crypto / aes-gcm.js View on Github external
const getKeyStringFromKey = async (key) => {
  const rawKey = await window.crypto.subtle.exportKey(RAW_KEY_TYPE, key)
  const keyString = base64.encode(rawKey)
  return keyString
}
github encrypted-dev / userbase / src / userbase-js / auth.js View on Github external
const masterKey = await crypto.hkdf.importMasterKey(seed)

  const encryptionKeySalt = crypto.hkdf.generateSalt()
  const dhKeySalt = crypto.hkdf.generateSalt()
  const hmacKeySalt = crypto.hkdf.generateSalt()

  const dhPrivateKey = await crypto.diffieHellman.importKeyFromMaster(masterKey, dhKeySalt)
  const publicKey = crypto.diffieHellman.getPublicKey(dhPrivateKey)

  try {
    const session = await api.auth.signUp(
      username,
      passwordSecureHash,
      base64.encode(publicKey),
      base64.encode(encryptionKeySalt),
      base64.encode(dhKeySalt),
      base64.encode(hmacKeySalt),
      email,
      profile,
      pbkdfKeySalt && base64.encode(pbkdfKeySalt),
      passwordEncryptedSeed && base64.encode(passwordEncryptedSeed)
    )
    return session
  } catch (e) {
    _parseUserResponseError(e, username)
  }
}
github leancloud / js-realtime-sdk / src / messages / binary-message.js View on Github external
toJSON() {
    return {
      ...super._toJSON(),
      data: encodeBase64(this.content),
    };
  }
github leancloud / js-realtime-sdk / src / messages / binary-message.js View on Github external
toFullJSON() {
    return {
      ...super.toFullJSON(),
      bin: true,
      data: encodeBase64(this.content),
    };
  }
}
github encrypted-dev / userbase / src / userbase-js / ws.js View on Github external
async validateKey() {
    const sharedKey = await crypto.diffieHellman.getSharedKeyWithServer(this.keys.dhPrivateKey)

    const validationMessage = base64.encode(await crypto.aesGcm.decrypt(sharedKey, this.encryptedValidationMessage))

    const action = 'ValidateKey'
    const params = { validationMessage }

    await this.request(action, params)
  }
github subdavis / Tusk / services / protectedMemory.js View on Github external
function prepData(data) {
		if (data === null || data === undefined || typeof (data) !== 'object')
			return data;

		if (data.constructor == ArrayBuffer || data.constructor == Uint8Array) {
			return randomString + Base64.encode(data);
		} else if (data.constructor == Array) {
			var newArray = new Array(data.length);
			for (var i = 0; i < data.length; i++) {
				newArray[i] = prepData(data[i]);
			}
			return newArray;
		} else {
			var newObject = {};
			for (var prop in data) {
				newObject[prop] = prepData(data[prop]);
			}
			return newObject;
		}
	}
github espresso-org / aragon-datastore / src / index.ts View on Github external
async setFileContent(fileId: number, file: ArrayBuffer) {
        await this._initialize()

        let byteLengthPreCompression = file.byteLength
        if (!JSZip.support.arraybuffer)
            throw new Error('Your browser does not support JSZip. Please install a compatible browser.')

        let zip = JSZip()
        zip.file('content', file)
        file = await zip.generateAsync({type : 'arraybuffer'})
        const contentStorageRef = await this._storage.addFile(file)
        let fileInfos = await this.getFileInfo(fileId)
        let jsonFileData = JSON.parse(Buffer.from(abBase64.encode(await this._storage.getFile(fileInfos.storageRef)), 'base64').toString('ascii'))
        jsonFileData.contentStorageRef = contentStorageRef
        jsonFileData.lastModification = new Date()
        jsonFileData.fileSize = byteLengthPreCompression
        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 encrypted-dev / userbase / src / userbase-js / auth.js View on Github external
const masterKey = await crypto.hkdf.importMasterKey(seed)

  const encryptionKeySalt = crypto.hkdf.generateSalt()
  const dhKeySalt = crypto.hkdf.generateSalt()
  const hmacKeySalt = crypto.hkdf.generateSalt()

  const dhPrivateKey = await crypto.diffieHellman.importKeyFromMaster(masterKey, dhKeySalt)
  const publicKey = crypto.diffieHellman.getPublicKey(dhPrivateKey)

  try {
    const session = await api.auth.signUp(
      username,
      passwordSecureHash,
      base64.encode(publicKey),
      base64.encode(encryptionKeySalt),
      base64.encode(dhKeySalt),
      base64.encode(hmacKeySalt),
      email,
      profile,
      pbkdfKeySalt && base64.encode(pbkdfKeySalt),
      passwordEncryptedSeed && base64.encode(passwordEncryptedSeed)
    )
    return session
  } catch (e) {
    _parseUserResponseError(e, username)
  }
}

base64-arraybuffer

Encode/decode base64 data into ArrayBuffers

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular base64-arraybuffer functions