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

TypeScript crypto.createDecipher函数代码示例

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

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



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

示例1: decrypt

  public decrypt(file: string, algorithm: string, password: string): void {
    let decipher = createDecipher(algorithm, password),
      decipherName = createDecipher(algorithm, password),
      decryptedFileName,
      encrypted,
      decrypted,
      pathArray,
      fileName,
      path;

    pathArray = file.split('/');
    fileName = pathArray.pop();
    path = pathArray.join('/');

    decryptedFileName = decipherName.update(fileName, 'hex', 'utf8');
    decryptedFileName += decipherName.final('utf8');
    path += '/' + decryptedFileName;

    encrypted = createReadStream(file);
    decrypted = createWriteStream(path);

    encrypted
      .pipe(decipher)
      .pipe(decrypted);
  }
开发者ID:robwormald,项目名称:xnb-crypto-ng2,代码行数:25,代码来源:cryptography.service.ts


示例2: decrypt

export function decrypt(text) {
  const cipher = crypto.createDecipher('aes-256-cbc', process.env.APP_KEY);
  let crypted = cipher.update(text, 'base64', 'utf8');
  crypted += cipher.final('utf8');

  return crypted;
}
开发者ID:Poniverse,项目名称:LunaTube,代码行数:7,代码来源:AuthHelpers.ts


示例3: decrypt

 export function decrypt(text: string, key: string): string {
     let cryptoKey = !key ? localKey : key;
     const cipher = crypto.createDecipher('aes-256-cbc',cryptoKey);
     var decipheredPlaintext = cipher.update(text,'hex','utf8');
     decipheredPlaintext += cipher.final('utf8');
     return decipheredPlaintext;
 }
开发者ID:jgkim7,项目名称:blog,代码行数:7,代码来源:crypto.ts


示例4: decrypt

    export function decrypt(input:string, secret:string, callback: (result: string) => void) : void {
    
        if(input) {

            if(secret) {

                try {

                    var decipher = crypto.createDecipher(algorithm, secret)

                    var result = decipher.update(input, 'hex', 'utf8') + decipher.final('utf8')

                    callback(result)

                } catch( e) {

                    callback(null)
                }

                return
            }
        }

        callback(null)
    }
开发者ID:sinclairzx81,项目名称:taxman,代码行数:25,代码来源:secret.ts


示例5: Buffer

 conn.query(q, args, (qerr, results) => {
     conn.release();
     if (qerr) {
         console.log('Error validating file id', qerr);
         return res.status(500).send({ Error: 'Internal Server Error' });
     }
     if (results.length < 1) {
         return res.status(404).send({ Error: 'No such file ID' });
     }
     const decipher = crypto.createDecipher('aes256', new Buffer(APP_CONFIG.storage_key, 'base64'));
     store.get(fileid).pipe(decipher).pipe(zlib.createGunzip()).pipe(res).once('close', () => res.end());
 });
开发者ID:TetuSecurity,项目名称:Crypt,代码行数:12,代码来源:files.ts


示例6: crypto_cipher_decipher_string_test

function crypto_cipher_decipher_string_test() {
	var key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
	var clearText:string = "This is the clear text.";
	var cipher:crypto.Cipher = crypto.createCipher("aes-128-ecb", key);
	var cipherText:string = cipher.update(clearText, "utf8", "hex");
	cipherText += cipher.final("hex");

	var decipher:crypto.Decipher = crypto.createDecipher("aes-128-ecb", key);
	var clearText2:string = decipher.update(cipherText, "hex", "utf8");
	clearText2 += decipher.final("utf8");

	assert.equal(clearText2, clearText);
}
开发者ID:Cyr1l,项目名称:DefinitelyTyped,代码行数:13,代码来源:node-tests.ts


示例7: _readTaskLibSecrets

    private static _readTaskLibSecrets(lookupKey: string): string {
        // the lookupKey should has following format
        // base64encoded<keyFilePath>:base64encoded<encryptedContent>
        if (lookupKey && lookupKey.indexOf(':') > 0) {
            let lookupInfo: string[] = lookupKey.split(':', 2);

            // file contains encryption key
            let keyFile = new Buffer(lookupInfo[0], 'base64').toString('utf8');
            let encryptKey = new Buffer(fs.readFileSync(keyFile, 'utf8'), 'base64');

            let encryptedContent: string = new Buffer(lookupInfo[1], 'base64').toString('utf8');

            let decipher = crypto.createDecipher("aes-256-ctr", encryptKey)
            let decryptedContent = decipher.update(encryptedContent, 'hex', 'utf8')
            decryptedContent += decipher.final('utf8');

            return decryptedContent;
        }
    }
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:19,代码来源:webClientFactory.ts


示例8: crypto_cipher_decipher_buffer_test

function crypto_cipher_decipher_buffer_test() {
	var key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
	var clearText:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4]);
	var cipher:crypto.Cipher = crypto.createCipher("aes-128-ecb", key);
	var cipherBuffers:Buffer[] = [];
	cipherBuffers.push(cipher.update(clearText));
	cipherBuffers.push(cipher.final());

	var cipherText:Buffer = Buffer.concat(cipherBuffers);

	var decipher:crypto.Decipher = crypto.createDecipher("aes-128-ecb", key);
	var decipherBuffers:Buffer[] = [];
	decipherBuffers.push(decipher.update(cipherText));
	decipherBuffers.push(decipher.final());

	var clearText2:Buffer = Buffer.concat(decipherBuffers);

	assert.deepEqual(clearText2, clearText);
}
开发者ID:Cyr1l,项目名称:DefinitelyTyped,代码行数:19,代码来源:node-tests.ts


示例9: decrypt

function decrypt(input: string): string {
    const decipher = crypto.createDecipher('aes256', config.security.passwordSecret);
    let output = decipher.update(input, 'base64', 'ascii');
    output += decipher.final('ascii');
    return output;
}
开发者ID:PhilipDavis,项目名称:react-redux,代码行数:6,代码来源:password.ts


示例10: stringDecrypt

export function stringDecrypt(text: string, pass: string): string {
	let decipher = crypto.createDecipher('aes-256-ctr', pass);
	let dec = decipher.update(text, 'hex', 'utf8');
	dec += decipher.final('utf8');
	return dec;
}
开发者ID:BCJTI,项目名称:typescript-express-seed,代码行数:6,代码来源:funcgen.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript crypto.createDecipheriv函数代码示例发布时间:2022-05-24
下一篇:
TypeScript crypto.createCipheriv函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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