[Issue 11757] toHexString doesn't support dynamic array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 17 05:33:13 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11757


Mathias LANG <pro.mathias.lang at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #2 from Mathias LANG <pro.mathias.lang at gmail.com> 2013-12-17 05:32:59 PST ---
(In reply to comment #1)
> (In reply to comment #0)
> 
> >     return hmac_md5(cast(ubyte[])(key), msg);
> 
> Don't use cast() unless you know what you are doing.
> 
> 
> > 'E0166C00000000000000000000000000'), but if you replace ubyte[] with ubyte[16]
> > -or auto-, it'll pass.
> 
> One advantage of the current design of toHexString() is that it can't fail,
> because the type system makes its usage safe and correct for most situations.
> (Unless you use cast() randomly).

Fair enough. I'm just a beginner, with a C[++] background, so keeping in mind
that string == immutable(char[]), chars are UTF-8, and my string is pure ASCII,
I "just" expected it to work.
I'll close this as invalid so, but I wouldn't be against an enlightment of
what's going on (and how to convert a string to an ubyte safely).
Thanks bearophile !

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list