当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript js-sha3.sha3_256函数代码示例

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


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

示例1: GenerateDirectoryHash

export function GenerateDirectoryHash(rootDir, chaincodeDir, hash) {
  var self = this;

  // Generate the project directory
  var projectDir = rootDir + "/" + chaincodeDir;

  // Read in the contents of the current directory
  var dirContents = fs.readdirSync(projectDir);
  var dirContentsLen = dirContents.length;

  // Go through all entries in the projet directory
  for (var i = 0; i < dirContentsLen; i++) {
    var current = projectDir + "/" + dirContents[i];

    // Check whether the entry is a file or a directory
    if (fs.statSync(current).isDirectory()) {
      // If the entry is a directory, call the function recursively.

      hash = self.GenerateDirectoryHash(rootDir, chaincodeDir + "/" + dirContents[i], hash);
    } else {
      // If the entry is a file, read it in and add the contents to the hash string

      // Read in the file as buffer
      var buf = fs.readFileSync(current);
      // Update the value to be hashed with the file content
      var toHash = buf + hash;
      // Update the value of the hash
      hash = sha3_256(toHash);
    }
  }

  return hash;
}
开发者ID:285452612,项目名称:fabric,代码行数:33,代码来源:sdk_util.ts

示例2: GenerateParameterHash

export function GenerateParameterHash(path, func, args) {
  debug("GenerateParameterHash...");

  debug("path: " + path);
  debug("func: " + func);
  debug("args: " + args);

  // Append the arguments
  var argLength = args.length;
  var argStr = "";
  for (var i = 0; i < argLength; i++) {
    argStr = argStr + args[i];
  }

  // Append the path + function + arguments
  var str = path + func + argStr;
  debug("str: " + str);

  // Compute the hash
  var strHash = sha3_256(str);
  debug("strHash: " + strHash);

  return strHash;
}
开发者ID:285452612,项目名称:fabric,代码行数:24,代码来源:sdk_util.ts


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