title: C# .net core encryption
body: <p>I'm trying to use a public key of a user to encrypt a string in a sort of <code>pgp</code> fashion, but I keep getting the error:</p>
  
  <pre><code>bignum routines:BN_mod_inverse:no inverse
  </code></pre>
  
  <p>I've looked around and I cannot find anything specific as to what I'm doing wrong. I've looked around for .NET core information, but I cannot seem to find anything relevant.</p>
  
  <p>I'm using the following code:</p>
  
  <pre><code>byte[] publicKey = Encoding.UTF8.GetBytes(key);
  
  RSA rsa = RSA.Create();
  RSAParameters RSAKeyInfo = new RSAParameters();
  
  RSAKeyInfo.Modulus = publicKey;
  RSAKeyInfo.Exponent = new byte[]{1,0,1};
  
  rsa.ImportParameters(RSAKeyInfo);
  var encrypted = rsa.Encrypt(Encoding.UTF8.GetBytes(user.challenge.text), RSAEncryptionPadding.Pkcs1);
  </code></pre>
  
  <p>It's entirely possible I'm going about this entirely wrong, so any thoughts or suggestions would be great!</p>