I want to encrypt card number. I have tried using this code
string public_key = "<RSAKeyValue><Modulus>" + modulus + "</Modulus><Exponent>" + exponent + "</Exponent></RSAKeyValue>";
RSACryptoServiceProvider cipher = null;
cipher = new RSACryptoServiceProvider();
cipher.FromXmlString(public_key);
byte[] data = Encoding.UTF8.GetBytes(cardnumber);
byte[] cipherText = cipher.Encrypt(data, false);
return Convert.ToBase64String(cipherText);
Here is my modulus and exponent
{ "modulus": "24130287975021244042702223805688721202041521798556826651085672609155097623636349771918006235309701436638877260677191655500886975872679820355397440672922966114867081224266610192869324297514124544273216940817802300465149818663693299511097403105193694390420041695022375597863889602539348837984499566822859405785094021038882988619692110445776031330831112388738257159574572412058904373392173474311363017975036752132291687352767767085957596076340458420658040735725435536120045045686926201660857778184633632435163609220055250478625974096455522280609375267155256216043291335838965519403970406995613301546002859220118001163241", "exponent": "415029", "prefix": "00008099" }
At this step it is throwing an exception.
cipher.FromXmlString(public_key);
invalid length for a base-64 char array or string. How can i get out of this exception?