本文整理汇总了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);
}
示例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();
}
})
示例3: deflate
export function deflate(obj) {
if (!obj) {
return null;
}
const json = JSON.stringify(obj);
const bytes = toByteArray(json);
return base64.fromByteArray(bytes);
}
示例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)
}
示例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)}`);
}
示例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));
示例7: key
key(method: string = 'p256dh'): string {
return fromByteArray(new Uint8Array(this.ps.getKey(method)));
}
示例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);
}