title: How to generate RSA key using sha512 for JWT?
body: <p>I understand that RSA keys can be generated using different <code>sha</code> algorithms. Using <code>openssl</code>, I don't seem to have the option of specifying what algorithm the key generator should use. I suspect it's using <code>sha256</code>.</p>
  
  <p>How can I generate RSA keys using different <code>sha</code> algorithms (such as <code>sha512</code>) in either a bash shell or in Ruby? Does the <code>openssl</code> library support generating RSA keys using different algorithms? If not, does anyone know of another library I can use? (In ruby, <code>OpenSSL::PKey::RSA</code> doesn't seem to allow for choosing an algorithm, but the <a href="http://ruby-doc.org/stdlib-2.4.1/libdoc/openssl/rdoc/OpenSSL/PKey/RSA.html" rel="noreferrer">documentation</a> is hard for me to follow soo...?)</p>
  
  <p>Apologies if this question has already been answered, but I haven't been able to find an answer.</p>
  
  <p>Maybe I should also note (in case I am wrong): it is my understanding that choosing a size for the generated RSA key (i.e. <code>RSA 2048</code>) is separate from choosing the hashing algorithm (i.e. <code>sha512</code>).</p>
  
  <p><strong>UPDATE - Some background</strong></p>
  
  <p>I want to sign Java Web Tokens with an RSA key. The <a href="https://github.com/jwt/ruby-jwt" rel="noreferrer">JWT library</a> I'm using gives me the impression that RSA keys can be generated using different hashing algorithms (RS256, RS384, RS512). Generating a key using <code>openssl</code> doesn't seem to let me choose what hashing algorithm is used though.</p>
  
  <p>Thanks!!</p>