title: In C#, how do I store large prime number?
body: <p>Good day everyone,</p>
  <p>I am attempting to implement the Diffie-Hellman key exchange protocol in C#.
  Before anything, this is <strong>a test project</strong>. I am aware that I should <strong>NOT</strong> use it for any real application. I am just doing this to learn a bit more about it.</p>
  <p>Now, according to this RFC (3526), I need to use the prime number P=<code>2^6144 - 2^6080 - 1 + 2^64 * { [2^6014 pi] + 929484 }</code> and the generator G=<code>2</code>.</p>
  <p><a href="https://datatracker.ietf.org/doc/html/rfc3526#page-6" rel="nofollow noreferrer">https://datatracker.ietf.org/doc/html/rfc3526#page-6</a></p>
  <p>But the prime number is a way too big ! Even for BigInteger !</p>
  <p>How do I proceed now ?</p>
  <p>EDIT:</p>
  <p>I assume it's too large because this piece of code return a negative value :</p>
  <pre><code>string hexString = &quot;...&quot;;
  BigInteger number = BigInteger.Parse(hexString, NumberStyles.AllowHexSpecifier);
  Console.WriteLine(&quot;Converted 0x{0}\nto\n{1}.&quot;, hexString, number);
  </code></pre>
  <p><a href="https://dotnetfiddle.net/Ffr7Ip" rel="nofollow noreferrer">https://dotnetfiddle.net/Ffr7Ip</a></p>