title: C# - How to calculate ASN.1 DER encoding of a particular hash algorithm?
body: <p>Given a hash algorithm like SHA1 or SHA256 how would I go about obtaining the ASN.1 DER encoding for it as defined in RFC3447? (see page 42 - <a href="http://www.ietf.org/rfc/rfc3447.txt" rel="noreferrer">link</a>) Below is the desired output.</p>
  
  <pre><code>MD5        30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 05 05 00 04 10
  SHA-1      30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14
  SHA-256    30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20
  SHA-384    30 41 30 0d 06 09 60 86 48 01 65 03 04 02 02 05 00 04 30
  SHA-512    30 51 30 0d 06 09 60 86 48 01 65 03 04 02 03 05 00 04 40
  </code></pre>
  
  <p>I'm hoping there is some intelligent way to do this in C# that doesn't require me to write an Oid to ASN.1 DER conversion routine (or hardcode them). Any ideas?</p>