Resumable MD5 Hash Algorithm

245 views
Skip to first unread message

Rong Shen

unread,
Feb 12, 2012, 2:28:12 AM2/12/12
to nodejs
I'm working on a resumable file upload program with Node.js.
For the identity checking of the uploaded file, I'm looking for a MD5
Hash Algorithm that could work in a resumable way.

Can anyone have any idea of it?

Thanks!

Rong Shen

Ben Noordhuis

unread,
Feb 12, 2012, 9:33:00 AM2/12/12
to nod...@googlegroups.com
On Sun, Feb 12, 2012 at 08:28, Rong Shen <rong...@gmail.com> wrote:
> I'm working on a resumable file upload program with Node.js.
> For the identity checking of the uploaded file, I'm looking for a MD5
> Hash Algorithm that could work in a resumable way.

You mean the built-in createHash() function?

var h = crypto.createHash('md5');
h.update(data);
h.update(moreData);
h.update(yetMoreData);
var d = h.digest();

Rong Shen

unread,
Feb 12, 2012, 10:48:49 PM2/12/12
to nodejs
You can not expect the next part of file will go to the same Node
process before when the file uploading working in resumable way.
That is the reason why h.update(data) does not work in this manner
(How could recovery a Hash object that worked before in another Node
process even in another server?).

On 2月12日, 下午10时33分, Ben Noordhuis <i...@bnoordhuis.nl> wrote:

Damianos Mylonakis

unread,
Feb 13, 2012, 7:02:47 AM2/13/12
to nod...@googlegroups.com
Save the hash-till-pause in some sort of database that every process
talks to.

Rong Shen

unread,
Feb 14, 2012, 12:37:33 AM2/14/12
to nodejs
but how to import the hash-till-pause back to the Hash Coder? I have
not found an API in Node for that.

Rong Shen

unread,
Feb 14, 2012, 3:46:57 AM2/14/12
to nodejs
I've resoved this by using SparkMD5 (https://github.com/satazor/
SparkMD5) , and use the psedo-code below:

var data1 = '1234qe2412eddadf24312312ddqwd';
var data2 = '5678123ljhlccwe12123121123111';

var spark1 = new SparkMD5();
spark1.append(data1);

var spark2 = new SparkMD5();
spark2._state = spark1._state;
spark2._buff = spark1._buff;
spark2._length = spark1._length;

spark2.append(data2);
var spark2Res = spark2.end();

Alan Gutierrez

unread,
Mar 4, 2012, 5:22:21 AM3/4/12
to nod...@googlegroups.com
I would be very interested in seeing resumable hashes and CRCs in the core API. Is this something that could happen?

--
Alan - @bigeasy

Ben Noordhuis

unread,
Mar 4, 2012, 6:18:22 PM3/4/12
to nod...@googlegroups.com
2012/3/4 Alan Gutierrez <al...@prettyrobots.com>:

> I would be very interested in seeing resumable hashes and CRCs in the core API. Is this something that could happen?

Probably not. The hash functions in Node are backed by OpenSSL which
doesn't have a notion of serializable digests.

Reply all
Reply to author
Forward
0 new messages