title: Ruby/Rails: Hashing array of participant phone numbers to uniquely identify a group/MMS text conversation?
body: <p>While I'm using Ruby/Rails to solve this particular problem, the specific issue is not unique to Ruby.</p>
  
  <p>I'm building an app that can send group/mms messages to multiple people, and then processes those texts when the others reply.</p>
  
  <p>The app will have a different number for each record, and each record can be involved in multiple group conversations.</p>
  
  <p>For example, <code>record_1</code> can be involved in a conversation with <code>user_1, user_2</code>, but can also be involved in a separate conversation with <code>user_2, user_3</code>, and <code>record_2</code> can have a separate conversation with <code>user_1, user_2</code>.</p>
  
  <p>When I send a message the fields resemble:</p>
  
  <pre><code>{
    from: "1234566789",
    to: [
      "1111111111",
      "2222222222",
      ...
    ],
    body: "..."
  }
  </code></pre>
  
  <p>Where the <code>from</code> is my app number, and the <code>to []</code> is an array of phone numbers for everyone else involved in the conversation.</p>
  
  <p>When one of the other participants replies to the group message, I'll get a webhook from my text messaging provider that has the <code>from</code> as that person's phone number and the <code>to []</code> would include my app number and everyone else's numbers.</p>
  
  <p>The identifier for a conversation is the unique combination of the phone numbers involved.</p>
  
  <p>However, having an array of <code>["1234567890", "1111111111", "2222222222"]</code> is difficult to work with, and I would like a string representation that I can index in my database and quickly find.</p>
  
  <p>If I have a <code>to: ["1234567890", "1111111111", "2222222222]</code> array of the phone numbers, I'm thinking about using <code>Digest::MD5.hexdigest to.sort.to_s</code>.</p>
  
  <p>This would give me a unique identifier such as <code>49a5a960c5714c2e29dd1a7e7b950741</code>, that I can index in my DB and use to uniquely reference conversations.</p>
  
  <p>Are there any concerns with using the MD5 hash to solve my specific problem? Anytime I have the same numbers involved in a conversation, I want it to produce the same hash. Does MD5 guarantee the same result given the same ordered input?</p>
  
  <p>Is there another approach to uniquely identify conversations by the participants?</p>