Closed GoogleCodeExporter closed 9 years ago
Original comment by cgdec...@gmail.com
on 28 Jun 2013 at 4:25
I think I implemented this as follows, but I am having some hassle with the
reflection based testing in guava.
Any thoughts ? Is this wanted, it would be super useful to have in guava proper.
Original comment by g.j.bow...@gmail.com
on 31 Jul 2013 at 1:05
Attachments:
From the email discussion we had that led to this feature request being filed...
You should be able to roundtrip them with BaseEncoding.base16().lowerCase():
HashCode hash1 = Hashing.sha1().hashString("Hello world");
String stringHash = hash1.toString();
HashCode hash2 = HashCodes.fromBytes(BaseEncoding.base16().lowerCase().decode(stringHash));
assertEquals(hash1, hash2);
Whether we want to add HashCodes.fromString() is still in the research
bucket...but thanks for voicing your positive vote for this API ;-)
Original comment by kak@google.com
on 31 Jul 2013 at 2:05
Humm ok, that feels a little none obvious but it works
Original comment by g.j.bow...@gmail.com
on 1 Aug 2013 at 8:46
I'm going to add this...still haven't decided on the name. Any opinions on
HashCodes.fromString(String) vs. HashCodes.fromHexString(String)?
Original comment by kak@google.com
on 1 Aug 2013 at 8:56
I'm mixed on that, because fromHexString is more descriptive, but fromString()
is properly parallel with toString (and I've tried to push the pattern of using
fromString() for toString()'s inverse and some tools like Caliper even exploit
that).
Original comment by kevinb@google.com
on 1 Aug 2013 at 9:01
I'm also +1 on fromString. The docs will explain it sufficiently.
Another question: do we want to be strict when de-hex'ing? Should we allow
both: "7f8005ff0e" and "7F8005FF0E"?
Keep in mind that toString() prints in lowercase.
Original comment by kak@google.com
on 1 Aug 2013 at 9:39
Going w/ fromString() and strict parsing for now.
Original comment by kak@google.com
on 6 Aug 2013 at 6:17
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<issue id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:12
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
simon.m.stewart
on 28 Jun 2013 at 1:28