c# - Generate a unique string based on a pair of strings -


i've 2 strings stringa, stringb. want generate unique string denote pair.

i.e.

f(x, y) should unique every x, y , f(x, y) = f(y, x) x, y strings.

any ideas?

compute message digest of both strings , xor values

md5(x) ^ md5(y) 

the message digest gives unique value each string , xor makes possible f(x, y) equal f(y, x).

edit: @phil h observed, have treat case in receive 2 equal strings input, generate 0 after xor. return md5(x+y) if x , y same, , md5(x) ^ md5(y) rest of values.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -