當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript base64-js.fromByteArray函數代碼示例

本文整理匯總了TypeScript中base64-js.fromByteArray函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fromByteArray函數的具體用法?TypeScript fromByteArray怎麽用?TypeScript fromByteArray使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fromByteArray函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: encryptMessage

    static encryptMessage(em: EphemeralMessage, fn?:()=>any) {
        // Generate a random, secure 256-bit master encryption key and salt
        em.mek = new Uint8Array(256 / 8);
        em.salt = new Uint8Array(256 / 8);
        crypto.getRandomValues(em.mek);
        crypto.getRandomValues(em.salt);

        // This will be the "lookup key" to identify
        // and unlock the message later on
        em.mekB64 = b64.fromByteArray(em.mek);
        em.saltB64 = b64.fromByteArray(em.salt);

        return this.applyKey(em, true, fn);
    }
開發者ID:ebekker,項目名稱:keypear,代碼行數:14,代碼來源:kp-crypto.ts

示例2: Uint8Array

                        crypto.subtle.encrypt(encryptAlgor, dekKey, dat).then((crypt: ArrayBuffer) => {
                            em.messageEnc = new Uint8Array(crypt);
                            em.messageEncB64 = b64.fromByteArray(em.messageEnc);

                            if (fn != null) {
                                fn();
                            }
                        })
開發者ID:ebekker,項目名稱:keypear,代碼行數:8,代碼來源:kp-crypto.ts

示例3: deflate

export function deflate(obj) {
  if (!obj) {
    return null;
  }
  const json = JSON.stringify(obj);
  const bytes = toByteArray(json);
  return base64.fromByteArray(bytes);
}
開發者ID:valotas,項目名稱:valotas.com,代碼行數:8,代碼來源:utils.ts

示例4: saveTypeCache

function saveTypeCache() {
	const composedCache: ComposedCache = {}
	for (const type in typeCache) {
		composedCache[type] = {
			sig: typeCache[type].sig,
			type: base64.fromByteArray(new Uint8Array(typeCache[type].type.toBuffer()))
		}
	}
	localStorage.typeCache = JSON.stringify(composedCache)
}
開發者ID:calebsander,項目名稱:structure-bytes,代碼行數:10,代碼來源:download.ts

示例5: encode

export function encode(data: any | null, type = 'text/plain') {
  // use FileReader if it's available, like in the browser
  if (FileReader) {
    return new Promise<string | ArrayBuffer | null>((resolve, reject) => {
      const reader = new FileReader();
      reader.onloadend = () => resolve(reader.result);
      reader.onerror = err => reject(err);
      reader.readAsDataURL(data);
    });
  }

  // otherwise fall back to fromByteArray
  // note: Buffer doesn't seem to correctly base64 encode binary data
  return Promise.resolve(`data:${type};base64,${fromByteArray(data)}`);
}
開發者ID:spalger,項目名稱:kibana,代碼行數:15,代碼來源:dataurl.ts

示例6: Uint8Array

import * as base64js from "base64-js";

const length: number = base64js.byteLength("");
const bytes: Uint8Array = base64js.toByteArray("");
const decoded: string = base64js.fromByteArray(new Uint8Array(0));
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:base64-js-tests.ts

示例7: key

 key(method: string = 'p256dh'): string {
   return fromByteArray(new Uint8Array(this.ps.getKey(method)));
 }
開發者ID:SuperSoe,項目名稱:mobile-toolkit,代碼行數:3,代碼來源:comm.ts

示例8: toDataUri

 toDataUri(imageData: ImageData): string {
   const header = this._createBMPHeader(imageData);
   imageData = this._imageDataToBMP(imageData);
   return 'data:image/bmp;base64,' + btoa(header) + fromByteArray(imageData.data);
 }
開發者ID:AlmogShaul,項目名稱:angular,代碼行數:5,代碼來源:bitmap.ts


注:本文中的base64-js.fromByteArray函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。