jchambers/fast-uuid

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

l0rinc opened this issue · 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.

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

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?

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.