本文整理汇总了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;未经允许,请勿转载。 |
请发表评论