title: Generating RSA-SHA1 signatures with JavaScript
body: <p>I'd like to generate RSA-SHA1 signatures with the <a href="http://kjur.github.com/jsrsasign/" rel="nofollow noreferrer">RSA-Sign JavaScript Library</a>. Specifically, I'd like to use this for signing OAuth requests.</p>
  <p>However, the signature generated by the JavaScript library looks different to the one I can generate e.g. with</p>
  <pre><code>$ echo -n &quot;x&quot; | openssl dgst -sha1 -sign priv.key -binary | openssl base64 | xargs echo -n
  eV0ZrD7ZrTsuzHHYSwLfUJhXuM96D6ZyIzD5FFphzHbKRaO4TMeTR7bJjkuPib+l
  EccM7t6YNDvRgOHyXJDVZZQTg5G4D4jnGVmOgeuti1etCCpLsb1Rl3sfJF/rIlgA
  AmejvBbrEG+n8L+GeD6Vd3cneW7k2Rksnh+/BWnnR3c=
  </code></pre>
  <p>In contrast: This is what the library generates (base64 encoded):</p>
  <pre><code>Nzk1ZDE5YWMzZWQ5YWQzYjJlY2M3MWQ4NGIwMmRmNTA5ODU3YjhjZjdhMGZhNjcy
  MjMzMGY5MTQ1YTYxY2M3Ng0KY2E0NWEzYjg0Y2M3OTM0N2I2Yzk4ZTRiOGY4OWJm
  YTUxMWM3MGNlZWRlOTgzNDNiZDE4MGUxZjI1YzkwZDU2NQ0KOTQxMzgzOTFiODBm
  ODhlNzE5NTk4ZTgxZWJhZDhiNTdhZDA4MmE0YmIxYmQ1MTk3N2IxZjI0NWZlYjIy
  NTgwMA0KMDI2N2EzYmMxNmViMTA2ZmE3ZjBiZjg2NzgzZTk1Nzc3NzI3Nzk2ZWU0
  ZDkxOTJjOWUxZmJmMDU2OWU3NDc3Nw==
  </code></pre>
  <p>(assuming the same input &amp; key, of course)</p>
  <p>Is it possible that this is because of the SHA1 implementation being used? In that case, I could try to use another one.</p>
  <p>I'm no expert of cryptography, but the OAuth RFC 5849 is <a href="https://www.rfc-editor.org/rfc/rfc5849#section-3.4.3" rel="nofollow noreferrer">saying</a> that RSASSA-PKCS1-V1_5-SIGN needs to be used, which seems to be the case for the library.</p>
  <p>Thank you very much.</p>