-3

Is there a function in Java that takes in two strings and generates one 16 character string which is unique to the given combination? I dont expect the string to be 100% unique as long as the probability of having 2 conflicting strings is very small (1 in 100,000 for example). Thanks.

user3245747
  • 805
  • 2
  • 17
  • 30

2 Answers2

1

You can concatenate both strings and hash them.

Marcin Szymczak
  • 11,199
  • 5
  • 55
  • 63
0

If it needs to be truly unique, then a concatenation of the strings which is 16 characters or less is your answer.

Else you have to rely on hashing. But that comes with no guarantee of a probability of clashing.

Your best bet is to use a GUID.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483