Discussion:
[dart-misc] crypto chunked hash
Istvan Soos
2016-09-07 10:18:25 UTC
Permalink
Hi,

I find the crypto package a bit confusing wrt/ how to calculate sha1 hash
of a big file. Does the team have an example on how they suggest doing that?

Setting the result object on the startChunkedConversion() call is not
really intuitive, and as there seems to be a pending breaking change
anyway, I'd suggest a different route:

- Move sha1 and similar variables into functions that takes a List<int>
and return a hash. Similar to the current convert() method, they don't
store or manipulate internal state, they may not be on the class.
- Make the Sha1Hash class implement the Sink or even the
ByteConversionSink interface, and on closing, calculate the digest.

Best regards,
Istvan
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Kevin Moore' via Dart Misc
2016-09-08 17:12:12 UTC
Permalink
See https://github.com/dart-lang/crypto/blob/master/example/hash.dart

This will make sure you don't load the entire file into memory. It streams
into the "hasher" and you get a result when you hit the end.

Let us know if you have other issues.
Post by Istvan Soos
Hi,
I find the crypto package a bit confusing wrt/ how to calculate sha1 hash
of a big file. Does the team have an example on how they suggest doing that?
Setting the result object on the startChunkedConversion() call is not
really intuitive, and as there seems to be a pending breaking change
- Move sha1 and similar variables into functions that takes a
List<int> and return a hash. Similar to the current convert() method, they
don't store or manipulate internal state, they may not be on the class.
- Make the Sha1Hash class implement the Sink or even the
ByteConversionSink interface, and on closing, calculate the digest.
Best regards,
Istvan
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
Istvan Soos
2016-09-08 22:51:03 UTC
Permalink
Thanks Kevin,

That is neat, it would be worth to put the bind part of that example
into the readme.

Thanks,
Istvan


On Thu, Sep 8, 2016 at 7:12 PM, 'Kevin Moore' via Dart Misc
Post by 'Kevin Moore' via Dart Misc
See https://github.com/dart-lang/crypto/blob/master/example/hash.dart
This will make sure you don't load the entire file into memory. It streams
into the "hasher" and you get a result when you hit the end.
Let us know if you have other issues.
Post by Istvan Soos
Hi,
I find the crypto package a bit confusing wrt/ how to calculate sha1 hash
of a big file. Does the team have an example on how they suggest doing that?
Setting the result object on the startChunkedConversion() call is not
really intuitive, and as there seems to be a pending breaking change anyway,
Move sha1 and similar variables into functions that takes a List<int> and
return a hash. Similar to the current convert() method, they don't store or
manipulate internal state, they may not be on the class.
Make the Sha1Hash class implement the Sink or even the ByteConversionSink
interface, and on closing, calculate the digest.
Best regards,
Istvan
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
'Kevin Moore' via Dart Misc
2016-09-15 19:46:10 UTC
Permalink
File an issue on the crypto repo – a great suggestion!
Post by Istvan Soos
Thanks Kevin,
That is neat, it would be worth to put the bind part of that example
into the readme.
Thanks,
Istvan
On Thu, Sep 8, 2016 at 7:12 PM, 'Kevin Moore' via Dart Misc
Post by 'Kevin Moore' via Dart Misc
See https://github.com/dart-lang/crypto/blob/master/example/hash.dart
This will make sure you don't load the entire file into memory. It
streams
Post by 'Kevin Moore' via Dart Misc
into the "hasher" and you get a result when you hit the end.
Let us know if you have other issues.
Post by Istvan Soos
Hi,
I find the crypto package a bit confusing wrt/ how to calculate sha1
hash
Post by 'Kevin Moore' via Dart Misc
Post by Istvan Soos
of a big file. Does the team have an example on how they suggest doing
that?
Post by 'Kevin Moore' via Dart Misc
Post by Istvan Soos
Setting the result object on the startChunkedConversion() call is not
really intuitive, and as there seems to be a pending breaking change
anyway,
Post by 'Kevin Moore' via Dart Misc
Post by Istvan Soos
Move sha1 and similar variables into functions that takes a List<int>
and
Post by 'Kevin Moore' via Dart Misc
Post by Istvan Soos
return a hash. Similar to the current convert() method, they don't
store or
Post by 'Kevin Moore' via Dart Misc
Post by Istvan Soos
manipulate internal state, they may not be on the class.
Make the Sha1Hash class implement the Sink or even the
ByteConversionSink
Post by 'Kevin Moore' via Dart Misc
Post by Istvan Soos
interface, and on closing, calculate the digest.
Best regards,
Istvan
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
Post by 'Kevin Moore' via Dart Misc
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to a topic in the
Google Groups "Dart Misc" group.
To unsubscribe from this topic, visit https://groups.google.com/a/
dartlang.org/d/topic/misc/PK0A5YaeO7E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...