Bug 24358 – std.digest on array of arrays surprisingly shallow

Status
NEW
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-27T04:53:33Z
Last change time
2024-12-01T16:42:19Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: phobos#9869 →

Comments

Comment #0 by schveiguy — 2024-01-27T04:53:33Z
std.digest when run on an array of arrays uses a blunt cast to ubyte[], which means it digests the pointer/lengths, not the contents of the subarrays. This can be surprising, and in some cases, leave a time bomb for future uses, because strings are interned. For example: `assert (md5Of(["hello", "world"]) == md5Of(["hello", "world"]));` passes `assert (md5Of(["hello", "world"]) == md5Of(["hello".dup, "world"]));` fails. ----- I propose that digest on an array of items which contain pointers does not just cast to ubyte[], but rather uses the (slower) range mechanism of applying digest to each item individually.
Comment #1 by robert.schadek — 2024-12-01T16:42:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9869 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB