Back

unique ID generation

  • 0
  • Databases
  • Flutter
  • Cloud
  • Accounts
Nuaiman
14 Jul, 2023, 19:00

Hello, I have a question, person 1 and 2 has uids.

I want to generate a third uid from the first two ids. This new ID should always be the same for only these two id combo and not any other combo.

Any ideas?

TL;DR
The user is looking for a way to generate a unique ID from two existing IDs, where the order of the IDs does not matter. They suggest using XOR or a hashing algorithm. One person suggests concatenating the IDs with a separator in between. The user thanks them but mentions that they want the third ID to be order independent. Another person suggests doing an XOR on both values. The user seems happy with this suggestion.
Drake
14 Jul, 2023, 19:58
TypeScript
thirdUid = firstUid + '|' + secondUid;

😁

Drake
14 Jul, 2023, 19:59

Or doing an XOR on both values

Nuaiman
14 Jul, 2023, 20:06

Thankyou @Steven.... But I require the third uid to be order independent from the first two

Nuaiman
14 Jul, 2023, 20:06

First+sec , sec+first should yeild the same unique result

Drake
14 Jul, 2023, 20:08

Xor should work then

Nuaiman
14 Jul, 2023, 20:08

What is xor?

Drake
14 Jul, 2023, 20:11

Exclusive or.

You can probably search online for stuff like this. You're looking for a hashing algorithm where order doesn't matter

Nuaiman
14 Jul, 2023, 20:11

I can do that with two, appwrite unique.IDs ?

Drake
14 Jul, 2023, 20:34

Yes

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more