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


TypeScript crypto.createDecipher函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。