當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。