title: RNGCryptoServiceProvider is obsolete
body: <p>I need to generate a token using random numbers and letters. However, the error message is telling me to use RandomNumberGenerator which will only give me random numbers which will not help.</p>
  <p>error messsage</p>
  <blockquote>
  <p>'RNGCryptoServiceProvider' is obsolete: 'RNGCryptoServiceProvider is obsolete. To generate a random number, use one of the RandomNumberGenerator static methods instead.'</p>
  </blockquote>
  <p>Code currently used</p>
  <pre><code>    private static string RandomString()
      {
          int length = 256;
          const string valid = &quot;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890&quot;;
          StringBuilder res = new StringBuilder();
          using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
          {
              byte[] uintBuffer = new byte[sizeof(uint)];
  
              while (length-- &gt; 0)
              {
                  rng.GetBytes(uintBuffer);
                  uint num = BitConverter.ToUInt32(uintBuffer, 0);
                  res.Append(valid[(int)(num % (uint)valid.Length)]);
              }
          }
          return res.ToString();
      }
  </code></pre>
  <p>How do I change the code above to use a package that is not out of date?</p>