title: How do I shorten and expand a uuid to a 15 or less characters
body: <p>Given a uuid(v4) without dashes, how can I shorten it to a 15 or less than 15 characters string? I should also be able to go back to the original uuid from the 15 characters string.</p>
  
  <p>I am trying to shorten it to send it in a flat file and the file format specifies this field to be a 15 characters alphanumeric field. Given that shortened uuid, I should be able to map it back to the original uuid.</p>
  
  <p>Here is what I tried, but definitely not what I wanted.</p>
  
  <pre><code>export function shortenUUID(uuidToShorten: string, length: number) {
    const uuidWithoutDashes = uuidToShorten.replace(/-/g , '');
    const radix = uuidWithoutDashes.length;
    const randomId = [];
  
    for (let i = 0; i &lt; length; i++) {
      randomId[i] = uuidWithoutDashes[ 0 | Math.random() * radix];
    }
    return randomId.join('');
  }
  </code></pre>