title: Algorithms: random unique string
body: <p>I need to generate string that meets the following requirements:</p>
  
  <ol>
  <li>it should be a unique string;</li>
  <li>string length should be 8 characters;</li>
  <li>it should contain 2 digits;</li>
  <li>all symbols (non-digital characters) should be upper case.</li>
  </ol>
  
  <p>I will store them in a data base after generation (they will be assigned to other entities).</p>
  
  <p>My intention is to do something like this:</p>
  
  <ol>
  <li>Generate 2 random values from 0 to 9&mdash;they will be used for digits in the string;</li>
  <li>generate 6 random values from 0 to 25 and add them to 64&mdash;they will be used as 6 symbols;</li>
  <li>concatenate everything into one string;</li>
  <li>check if the string already exists in the data base; if not&mdash;repeat.</li>
  </ol>
  
  <p>My concern with regard to that algorithm is that it doesn't guarantee a result in finite time (if there are already A LOT of values in the data base).</p>
  
  <p>Question: could you please give advice on how to improve this algorithm to be more deterministic?</p>
  
  <p>Thanks.</p>