jchambers / fast-uuid

A Java library for quickly and efficiently parsing and writing UUIDs
MIT License
162 stars 18 forks source link

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

Open l0rinc opened 5 years ago

l0rinc commented 5 years ago

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.

jchambers commented 5 years ago

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

jchambers commented 4 years ago

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?

l0rinc commented 4 years ago

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.