本文整理匯總了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;
}