This is the simplest version I could think of. This may not be optimal
and may not use the full power of Crypto++ (maybe Jeffrey knows more).

BR

JPM

Code:

// returns the hash, reads from In and forwards In to Out
SecByteBlock sha1stream(std::fstream<byte>& In, std::fstream<byte>& Out) // out 
may be optional for you
{
        byte buffer; // do it byte-by-byte
        CryptoPP::Weak::SHA1 Instance; // you must omit the "Weak" if you're 
using <=5.6.2
        while(In.get(buffer)) // returns true if successful and false otherwise
        {
                Instance.Update(buffer,1); //process
                Out.write(buffer,1); // pass to next "consumer"
        }
        buffer=0; //clean buffer up
        FixedSizeSecBlock<byte,20> Output; // we know the size in advance
        Instance.Final(Output);
        return Output;
}


Am 16.10.2015 um 14:10 schrieb Goran:
> Hi all,
>
> I'm using Crypto++ the first time and wondering how I can get the
> sha1sum of a simple std::fstream?
>
> Thanks
> -- 
> -- 
> You received this message because you are subscribed to the "Crypto++
> Users" Google Group.
> To unsubscribe, send an email to
> [email protected].
> More information about Crypto++ and this group is available at
> http://www.cryptopp.com.
> ---
> You received this message because you are subscribed to the Google
> Groups "Crypto++ Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to