brad clawsie:

      auto digest = HMAC(EVP_sha1(),
                         cast(void *) key,

Better to attach the * to void.


                         cast(int) key.length,
                         cast(ubyte*) s,

Here you are casting a struct of pointer to immutable plus length to a mutable ubyte pointer.


                         cast(int) s.length,
                         null,null);

This whole function call is quite bug-prone.


"digest" should be of type ubyte*

does anyone know how to print this out as ascii?

Do you mean in hex? Perhaps something like this? But hardcodes the hash function output length:

writefln("%-(%02x%)", digest[0 .. 40])

Bye,
bearophile

Reply via email to