本文整理汇总了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;
}
示例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;
}