On 2010-07-13, Alex Osborne <a...@meshy.org> wrote: > Hi David, > > David Soria Parra <d...@php.net> writes: >> any feeback on this so far? > >>> A typical example would be: >>> (digest-to-str (digest "hello world" :algorithm "SHA-1")) > > "digest-to-str" is a bit misleading as hexadecimal digits are not the > only way you can represent a digest as a string: base 64 and base 32 are > also quite common. Yes. I wonder if we should add base32 to digest or leave it for a encoding? base64 is there already, so this shouldn't be an issue. Probably I should name the function hexdigest.
> Additionally, named arguments are typically useful when the arguments > are optional or there's a lot of them. I'd probably just drop the >:algorithm keyword, since you're always going to need to specify it. Thanks, will do. > Something important that you don't seem to be covering is incremental > digests (using the .update method). I'm not sure what the best way to > expose this is (push or pull: update-digest vs passing in a lazy seq), > but most non-trivial uses of digests are going to want to be able to do > things incrementally. In my experience it's very bad to encourage > people to load full datasets into memory where it's unnecessary (even > just the simple cases of sha1summing a file) -- that road leads to > brittle applications and OutOfMemoryErrors. I gave this some thought and I think it would be best if we use lazy sequences. The standard Java API is so easy to wrap that update-digest is not much better than calling (.update) directly. > One might argue that this is just a convenience for trivial string and > byte array usage and that anybody doing it incrementally should use the > raw MessageDigest API, but at the end of the day, if somebody provides > some sort of Clojure API many people are going to try and shoehorn all > their uses into it. I agree that it's better if I enhance the current implementation. I'll continue hacking on this stuff in about a week or so. Thanks for the review. David > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en