fast-uuid icon indicating copy to clipboard operation
fast-uuid copied to clipboard

Add method to create hash String from byte[] and long/long

Open l0rinc opened this issue 6 years ago • 3 comments

Hey, thanks for sharing this little library!

Since UUIDs are sometimes the result of hashing calculations (e.g. MessageDigest.getInstance("md5")#digest), it may make sense to extend the lib with FastUUID.toString(byte[] uuid) and FastUUID.toString(long mostSignificantBits, long leastSignificantBits).

I would gladly contribute this change, if you think it makes sense.

l0rinc avatar Sep 19 '19 08:09 l0rinc

Interesting. I think that makes sense, but will have to page this back into my head. Let me get back to you shortly!

jchambers avatar Sep 19 '19 17:09 jchambers

With apologies for the long delay, I'm finally getting back to this. I get that you're talking about version 3 and 5 UUIDs, but don't quiiiiiite follow the use case for going straight from byte[] to String (as opposed to, say, UUID FastUUID#fromBytes(byte[])). I'm not necessarily opposed (and suspect you're just trying to save some overhead in a case where you just want to dump something straight to text), but can you say more?

jchambers avatar Jan 02 '20 18:01 jchambers

We're storing it in the db and getting back a byte array - would be great to be able to avoid the intermediary UUID object and convert from byte[] to String and vice versa (i.e. md5 produces the array and postgres requires a formatted String (with or without dashes)). I've already implemented this for our case so - I can share the code already, if you think it would be useful for others as well.

l0rinc avatar Jan 02 '20 18:01 l0rinc