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

TypeScript crypto.createCipher函数代码示例

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

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



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

示例1: encrypt

  public encrypt(file: string, algorithm: string, password: string): void {
    let cipher = createCipher(algorithm, password),
      cipherName = createCipher(algorithm, password),
      encryptedFileName,
      decrypted,
      encrypted,
      pathArray,
      fileName,
      path;

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

    mkdir(path);

    encryptedFileName = cipherName.update(fileName, 'utf8', 'hex');
    encryptedFileName += cipherName.final('hex');
    path += '/' + encryptedFileName;

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

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


示例2: encrypt

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

                try {

                    var cipher = crypto.createCipher(algorithm, secret)
         
                    var result = cipher.update(input, 'utf8', 'hex') + cipher.final('hex')

                    callback(result)

                } catch( e) {

                    callback(null)
                }

                return
            }
        }

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


示例3: encrypt

 encrypt(value) {
     let cipher = crypto.createCipher('aes-256-ctr', this.secretKey.value);
     let encrypted = cipher.update(value, 'utf8', 'binary');
     encrypted += cipher.final('binary');
     let hexVal = new Buffer(encrypted, 'binary');
     return hexVal.toString('base64');
 }
开发者ID:workfel,项目名称:vulcain-corejs,代码行数:7,代码来源:crypto.ts


示例4: encrypt

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


示例5: encrypt

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

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


示例6:

export const cryptoPassword = (password: string) => {
  // 先 md5 不可逆加密
  const md5 = crypto.createHash('md5')
  md5.update(password, 'utf8')
  const md5Str = md5.digest('hex')
  // 再 aes 对称加密(密匙私有!)
  const aes = crypto.createCipher('aes-256-cbc', process.env.PASSWORD_SECRET)
  return aes.update(md5Str, 'utf8', 'hex') + aes.final('hex')
}
开发者ID:linkFly6,项目名称:Said,代码行数:9,代码来源:admin-service.ts


示例7: 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


示例8: 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.send(404).send({ Error: 'No such file ID' });
     }
     const cipher = crypto.createCipher('aes256', new Buffer(APP_CONFIG.storage_key, 'base64'));
     let pl = req.pipe(zlib.createGzip()).pipe(cipher);
     store.store(fileid, pl, function (perr) {
         if (perr) {
             return res.status(500).send({ Error: perr });
         }
         return res.send({ Success: true });
     });
 });
开发者ID:TetuSecurity,项目名称:Crypt,代码行数:18,代码来源:files.ts


示例9: 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


示例10: getEncAse192

export function getEncAse192(str, secret = 'lqbw') {
  const cipher = crypto.createCipher('aes192', secret);
  let enc = cipher.update(str, 'utf8', 'hex');
  enc += cipher.final('hex');
  return enc;
}
开发者ID:knarfeh,项目名称:eebookorg,代码行数:6,代码来源:util.ts


示例11: encrypt

//
// Encrypt the password hash using a secret from our config file.
// We do this so if an attacker acquired the database (e.g. through
// SQL injection) then the password hashes will be unreadable.
//
function encrypt(input: string): string {
    const cipher = crypto.createCipher('aes256', config.security.passwordSecret);
    let output = cipher.update(input, 'ascii', 'base64');
    output += cipher.final('base64');
    return output;
}
开发者ID:PhilipDavis,项目名称:react-redux,代码行数:11,代码来源:password.ts


示例12: encrypt

export function encrypt(text:string) : string {
  var cipher = crypto.createCipher(algorithm,config.secret);
  var crypted = cipher.update(text,'utf8','hex');
  crypted += cipher.final('hex');
  return crypted;
}
开发者ID:D10221,项目名称:koapp,代码行数:6,代码来源:index.ts


示例13: encrypt

 /**
  * Encrypt
  * @param  {string} str
  * @param  {string} password
  * @param  {string} algo
  * @return {string}
  */
 public static encrypt(str: string, password: string, algo: string): string {
   let cipher = crypto.createCipher(algo, password);
   let crypted = cipher.update(str, 'utf8', 'hex');
   crypted += cipher.final('hex');
   return crypted;
 }
开发者ID:chen-framework,项目名称:chen,代码行数:13,代码来源:crypto.ts


示例14: stringEncrypt

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


示例15: encrypt

export function encrypt(text: string, key: string) {
    return evaluate('utf8', 'hex', text, createCipher(ALGORITHM, key));
}
开发者ID:consumr-project,项目名称:cp,代码行数:3,代码来源:crypto.ts


示例16: encryptText

export function encryptText(text: string): string {
	let cipher = crypto.createCipher("aes-256-ctr", config.tokenPassword);
	let crypted = cipher.update(text, "utf8", "hex");
	crypted += cipher.final("hex");
	return crypted;
}
开发者ID:kayateia,项目名称:flowerbox-server,代码行数:6,代码来源:Crypto.ts


示例17: encrypt

function encrypt(password: any, obj: any): Buffer {
    const json = JSON.stringify(obj);
    const cipher = crypto.createCipher(algorithm, password);
    return Buffer.concat([cipher.update(new Buffer(json, 'utf8')), cipher.final()]);
}
开发者ID:StrideSpark,项目名称:kms-datakeys,代码行数:5,代码来源:index.ts


示例18: Buffer

    {
        var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
    }

    {
        let hmac: crypto.Hmac;
        (hmac = crypto.createHmac('md5', 'hello')).end('world', 'utf8', () => {
            let hash: Buffer | string = hmac.read();
        });
    }

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

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

        assert.equal(clearText2, clearText);
    }

    {
        //crypto_cipher_decipher_buffer_test
        let key: Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
        let clearText: Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4]);
        let cipher: crypto.Cipher = crypto.createCipher("aes-128-ecb", key);
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:node-tests.ts


示例19: encrypt

 encrypt(value: string) {
   const cipher = crypto.createCipher('aes256', this._key);
   return cipher.update(value, 'utf8', 'hex') + cipher.final('hex');
 }
开发者ID:Codesleuth,项目名称:hubot-appveyor,代码行数:4,代码来源:secure_brain.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript crypto.createCipheriv函数代码示例发布时间:2022-05-24
下一篇:
TypeScript crossroads.parse函数代码示例发布时间: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