title: How to generate a pseudorandom 32-byte string for use as a salt in a cryptographic hash function?
body: <p>I am trying to code a password encryption function in C++ (Note: for educational purposes only. I won't actually be storing my passwords with it.) but I am not sure how to create a random 32-byte salt using a predefined characterset. How would I do this?</p>
  
  <pre><code>#include &lt;random&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  
  void genSalt() {
  
      const char charset[] = {
  
          "0123456789"
          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
          "abcdefghijklmnopqrstuvwxyz"
          "!£$%^&amp;*():@~#'?/&gt;&lt;.,|`¬¦"
  
      };
  
  }
  </code></pre>
  
  <p>The code should generate a random 32-byte string based on the defined character set 'charset'. I am not sure how to achieve this.</p>