>>>>> "Michel" == Michel Schinz <Michel.Schinz@epfl.ch> writes:
Michel> Martin Gasbichler <firstname.lastname@example.org> writes:
Michel> I've a first question here: Is it really useful to have separate
Michel> creation (make-md5-context) and initialisation (init-md5-context!)
Michel> functions? Wouldn't it be simpler if we had only one
Michel> create-and-initialise function? The only disadvantage I could see with
Michel> a unique function is that you could not re-initialise an md5 context,
Michel> but creating a new one is always possible, and unless it's very
Michel> expensive, it should be OK.
No, creating a context is not expensive at all. Earlier I thought about
hiding the above direct bindings from the programmer, but then
realized that this is not useful. I'll discard init-md5-context! and
let make-md5-context do the job.
Michel> (I guess the three "md5-digit" above should be "md5-digest")
>> (md5-digest->number md5-digest) -> number
>> (md5-digest->string md5-digest) -> string
>> (string->md5-digest string) -> md5-digest
>> (number->md5-digest number) -> md5-digest
Michel> Other question here: why have a separate type for md5-digest? Why not
Michel> use Scheme bignums directly, which could then be converted to and from
Michel> strings using standard R5RS functions?
The string returned by md5-digest->string is not the same as you would
get from (number->string (md5-digest->number md5-digest)) but more
Michel> Also, I do not really see the aim of "string->md5-digest" and
Michel> "number->md5-digest" since apparently the only thing you can do with
Michel> the returned md5-digest is convert it back to a number or a string.
I just don't like the idea of numbers with special meanings floating
around in the program. Scsh has enough of them already. You can't do
anything reasonable with a md5-digest than reading, writing and
comparing them, so we not help the programmer with enforcing this.
btw: (md5-digest=? md5-digest md5-digest) -> bool is missing.
>> The following high-level procedures compute digests for strings and
>> (md5-digest-for-string string) -> md5-digest
>> (md5-digest-for-string port [buffersize]) -> md5-digest
Michel> (I guess the second one is called "md5-digest-for-port", no?)
Got me again.
Michel> It might be nice to provide an "md5-digest-for-file" procedure, taking
Michel> a file-name as argument, I guess it's a pretty common operation.
Hmm, in the scsh tradition it should be
(md5-digest-for-file fname/port/fd [buffersize] -> md5-digest
Michel> As a side-remark, I would add that sometimes one needs to perform
Michel> checksums but without the cryptographic guarantees that MD5 gives. In
Michel> these cases, one can use checksum algorithms which are much much
Michel> faster than MD5. A good example is the FNV checksum algorithm ,
Michel> which appears to have a very low probability of collision, like MD5,
Michel> while being faster and a lot easier to compute. Maybe also having this
Michel> one in scsh would be nice.
Michel>  http://www.isthe.com/chongo/tech/comp/fnv/
Okay, I'll put that into my queue. I the new FFI stub generator my
students are working on should already handle this...