std.hash design
Regan Heath
regan at netmail.co.nz
Mon Jun 25 05:42:43 PDT 2012
On Fri, 22 Jun 2012 18:34:10 +0100, Johannes Pfau <nospam at example.com>
wrote:
> Am Fri, 22 Jun 2012 18:12:20 +0100
> schrieb "Regan Heath" <regan at netmail.co.nz>:
>
>
>>
>> Agreed. In fact I wouldn't bother with finishString either TBH,
>> people can always pass the result of finish string into the method
>> which produces the hex string representation.
>>
>>
>> In any case, we can probably have one static toHexString method for
>> all digests.
>
> string digestToString(size_t num)(in ubyte[num] digest)
> {
> auto result = new char[num*2];
> size_t i;
>
> foreach(u; digest)
> {
> result[i++] = std.ascii.hexDigits[u >> 4];
> result[i++] = std.ascii.hexDigits[u & 15];
> }
> return assumeUnique(result);
> }
>
> adapted from std.md5. I don't really like the name though ;-)
Name seems fine to me. Alternately just digestString or even the
completely generic "hexString".
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list