Generate composite UUID from two UUIDs

跟風遠走 提交于 2020-12-08 06:09:53

问题


If I have two UUIDs, is there a "safe" method to generate a third composite UUID. That is to some statistical definition of the word unique. So I'm looking for function f below in

UUID generatedUUID = f(UUID a, UUID b)

XOR?


回答1:


Depending on where you're getting the two UUIDs from, UUID V3/V5 may be applicable, and any decent library should have functions to generate those. Even if they're not quite right logically, you may be able to abuse them for that purpose anyway. You'd have to explain why you're trying to combine two UUIDs in the first place for us to be sure.

In any case, do not use a simple XOR (or other generic operation) on two UUID values because that will likely mess up the version/variant fields, giving you a result that is not itself a valid UUID or, worse, collides with a valid UUID that should not otherwise be collidible.



来源:https://stackoverflow.com/questions/33866477/generate-composite-uuid-from-two-uuids

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!