• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript base64-js.toByteArray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中base64-js.toByteArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toByteArray函数的具体用法?TypeScript toByteArray怎么用?TypeScript toByteArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了toByteArray函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: Uint8Array

                        false, ['encrypt','decrypt']).then((dekKey: CryptoKey) => {

                    let dat: Uint8Array;

                    if (encrypt) {
                        // Encode the message string as a byte array
                        dat = textEncoder.encode(em.message);
                        // Generate a random IV for seeding AES-CBC
                        em.iv = new Uint8Array(16);
                        crypto.getRandomValues(em.iv);
                        // Encode the IV to be persisted later
                        em.ivB64 = b64.fromByteArray(em.iv);
                    }
                    else {
                        // Decode the IV
                        em.iv = b64.toByteArray(em.ivB64);
                        // Decode the encrypted message
                        em.messageEnc = b64.toByteArray(em.messageEncB64);
                        dat = em.messageEnc;
                    }

                    // Setup the encryptiong/decryption parameters
                    let encryptAlgor = {
                        name: 'AES-CBC',
                        iv: em.iv,
                    };

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

                            if (fn != null) {
                                fn();
                            }
                        })
                    }
                    else {
                        crypto.subtle.decrypt(encryptAlgor, dekKey, dat).then((clear: ArrayBuffer) => {
                            em.message = textDecoder.decode(new Uint8Array(clear));
                            
                            if (fn != null) {
                                fn();
                            }
                        })
                    }
                });
开发者ID:ebekker,项目名称:keypear,代码行数:48,代码来源:kp-crypto.ts


示例2: loadConsumer

function loadConsumer(source: string): SourceMapConsumer {
  let consumer = consumers.get(source);
  if (consumer == null) {
    const code = getGeneratedContents(source);
    if (!code) {
      return null;
    }

    let sourceMappingURL = retrieveSourceMapURL(code);
    if (!sourceMappingURL) {
      throw Error("No source map?");
    }

    let sourceMapData: string;
    if (reSourceMap.test(sourceMappingURL)) {
      // Support source map URL as a data url
      const rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
      const ui8 = base64.toByteArray(rawData);
      sourceMapData = arrayToStr(ui8);
      sourceMappingURL = source;
    } else {
      // Support source map URLs relative to the source URL
      //sourceMappingURL = supportRelativeURL(source, sourceMappingURL);
      sourceMapData = getGeneratedContents(sourceMappingURL);
    }

    //console.log("sourceMapData", sourceMapData);
    const rawSourceMap = JSON.parse(sourceMapData);
    consumer = new SourceMapConsumer(rawSourceMap);
    consumers.set(source, consumer);
  }
  return consumer;
}
开发者ID:elisaado,项目名称:deno,代码行数:33,代码来源:v8_source_maps.ts


示例3: inflate

export function inflate(input: string) {
  if (!input) {
    return input;
  }
  const bytes = base64.toByteArray(input);
  const restored = toString(bytes);
  return JSON.parse(restored);
}
开发者ID:valotas,项目名称:valotas.com,代码行数:8,代码来源:utils.ts


示例4: unpack

function unpack(data: string): Uint32Array {
  const binary = base64js.toByteArray(data);
  const bits = binary[0];
  const values = new Uint32Array((binary.length - 1) / bits);
  for (let i = 1; i < binary.length; i += bits) {
    // Values are written little-endian.
    for (let j = bits - 1; j >= 0; j--) {
      values[(i - 1) / bits] <<= 8;
      values[(i - 1) / bits] |= binary[i + j] | 0;
    }
  }
  return values;
}
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:13,代码来源:indexes.ts


示例5: decompressCode

function decompressCode(compressedCode: string): string {
  return String.fromCharCode(...GZip.unzip(Base64.toByteArray(compressedCode)));
}
开发者ID:alangpierce,项目名称:sucrase,代码行数:3,代码来源:URLHashState.ts


示例6:

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: decryptMessage

    static decryptMessage(em: EphemeralMessage, fn?:()=>any) {
        em.mek = b64.toByteArray(em.mekB64);
        em.salt = b64.toByteArray(em.saltB64);

        return this.applyKey(em, false, fn);
    }
开发者ID:ebekker,项目名称:keypear,代码行数:6,代码来源:kp-crypto.ts


示例8:

/// <reference path="base64-js.d.ts" />

import * as base64js from 'base64-js';

const bytes: Uint8Array = base64js.toByteArray('shemp');
const decoded: string = base64js.fromByteArray(new Uint8Array(0));
开发者ID:1drop,项目名称:DefinitelyTyped,代码行数:6,代码来源:base64-js-tests.ts


示例9:

import * as base64js from "base64-js";

base64js.byteLength(""); // $ExpectType number
base64js.toByteArray(""); // $ExpectType Uint8Array
base64js.fromByteArray(new Uint8Array(0)); // $ExpectTpe string
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:5,代码来源:base64-js-tests.ts


示例10: 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)
}
if (localStorage.typeCache) {
	const composedCache: ComposedCache = JSON.parse(localStorage.typeCache)
	for (const typeName in composedCache) {
		typeCache[typeName] = {
			sig: composedCache[typeName].sig,
			type: r.type(base64.toByteArray(composedCache[typeName].type).buffer)
		}
	}
}

export interface DownloadOptions {
	name: string
	url: string
	options?: RequestInit
}
export function download({name, url, options}: DownloadOptions): Promise<any> {
	assert.instanceOf(name, String)
	assert.instanceOf(url, String)
	options = options || {}
	assert.instanceOf(options, Object)
	const typeInCache = typeCache[name]
开发者ID:calebsander,项目名称:structure-bytes,代码行数:31,代码来源:download.ts



注:本文中的base64-js.toByteArray函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript base64url.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript base64-js.fromByteArray函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap