#894 digest stream?

liamstask Sun 3 Jan 2010

I'd like to generate a digest (md5 particularly) for a stream as it comes in. I have a Buf which stores chunks of the stream as they come through, and I'd like to be able to generate the digest for all the information that has been streamed, although of course it's not all in memory at once so Buf.toDigest() doesn't work. I'm thinking of something along the lines of java.security.DigestInputStream.

Is there a reasonable option for this in Fantom, or should I consider using the java implementation? Thanks.

brian Sun 3 Jan 2010

I put the simple stuff into Buf to keep simple stuff easy one liners.

My vision for the more complex stuff is to create a real Fantom crypto pod with APIs for stream oriented digests, encryption, SSL, etc.

BTW, the crypto API would be a great place to get community involvement.

But until then you just might want to use Java FFI.

liamstask Sun 3 Jan 2010

OK - good to know, thanks.

Are there any other discussions relevant to a potential crypto API? A quick search here didn't turn up much, and it would be helpful to know whether this is truly starting from scratch or not. Perhaps it's worth opening up a discussion item for it?

katox Sun 3 Jan 2010

Fantom crypto must be written in pure Fantom or it is sufficient to find a Java or even C library and provide a mapping to Fantom API? Getting these things right is tricky and if it also have to be of a reasonable performance...

brian Mon 4 Jan 2010

No work has been on a crypto API, but it is the probably the biggest missing API still missing from what I consider the required core pods.

Implementation in pure Fantom would be nice, but I think this is a case where it is better to wrap existing Java/C# libraries.

Login or Signup to reply.