[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

manipulating Digest state

leon breedt

11/5/2004 5:16:00 AM

Hi,

Perhaps this is not possible, but I was wondering if there was a way
to save/load the state of a Digest. Not the digest value itself but
the state that gives a particular digest value.

Why?

If I am retrieving some data, and update the digest as I receive
bytes, it would be more efficient if I could store the state that
would give me the digest of the data up to a certain point, as I can
avoid rescanning the data when resuming an interrupted retrieval and
just "resume" the digest update as well, especially as the file size
increases.

Is this at all feasible? (Leaving security/integrity concerns aside).

Leon


1 Answer

Eivind Eklund

11/5/2004 7:54:00 AM

0

On Fri, 5 Nov 2004 14:16:08 +0900, leon breedt <bitserf@gmail.com> wrote:
> Hi,
>
> Perhaps this is not possible, but I was wondering if there was a way
> to save/load the state of a Digest. Not the digest value itself but
> the state that gives a particular digest value.

Unless the Digest class is "special", you should be able to just data
= Marshal.dump(digest) and restoire with Marshal.load(data).

> Is this at all feasible? (Leaving security/integrity concerns aside).

Yes. The security side is also fairly OK (primary new issues:
Synchronized disk writes and access permissions to aborted fil;e and
serialized Digest, and the increased corruption time window.)

Eivind.
--
Hazzle free packages for Ruby?
RPA is available from http://www.rubyar...