想不到有什麼相關的 library 可以做到,如果是 CryptoJS 可以做到的話也請告知一下 因為我目前只會把 string 換成 hash 希望可以做到新增一個 pdf 或其他檔案 會把其轉成 hASH 值 http://www.atool.org/file_hash.php 感謝各位
|  |      1cctrv      2017-10-16 03:56:28 +08:00 node 走 shell 去獲得 sha256 Google 兩套關鍵字「 node shell command 」和「 sha256 terminal 」 https://stackoverflow.com/questions/3358420/generating-a-sha256-from-the-linux-command-line https://www.npmjs.com/package/shelljs | 
|  |      2cctrv      2017-10-16 04:00:41 +08:00 或者用這個 https://www.hacksparrow.com/how-to-generate-md5-sha1-sha512-sha256-checksum-hashes-in-node-js.html var crypto = require('crypto'); var fs = require('fs'); // change the algo to sha1, sha256 etc according to your requirements var algo = 'md5'; var shasum = crypto.createHash(algo); var file = './kitten.jpg'; var s = fs.ReadStream(file); s.on('data', function(d) { shasum.update(d); }); s.on('end', function() { var d = shasum.digest('hex'); console.log(d); }); |