推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
ricky321u

把檔案利用 sha256 來計算 hash 值 利用 js 或 node.js

  •  
  •   ricky321u · Oct 12, 2017 · 2239 views
    This topic created in 3157 days ago, the information mentioned may be changed or developed.

    想不到有什麼相關的 library 可以做到,如果是 CryptoJS 可以做到的話也請告知一下 因為我目前只會把 string 換成 hash 希望可以做到新增一個 pdf 或其他檔案 會把其轉成 hASH 值 http://www.atool.org/file_hash.php 感謝各位

    2 replies    2017-10-16 04:00:41 +08:00
    cctrv
        1
    cctrv  
       Oct 16, 2017
    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
    cctrv
        2
    cctrv  
       Oct 16, 2017
    或者用這個

    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);
    });
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3174 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 14:00 · PVG 22:00 · LAX 07:00 · JFK 10:00
    ♥ Do have faith in what you're doing.