-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
  • 825
  • 2
  • 13
  • 26

2 Answers2

1

You can concatenate both strings and hash them.

Marcin Szymczak
  • 9,665
  • 4
  • 48
  • 60
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
  • 220,365
  • 33
  • 331
  • 451