RSA Encryption with public Key

Hi, I am tryint to encryp username and password and send it to a website with RSA.


I've been searching the web and didn't find any thing.


I get the Public Key from a .Net WebServer in XML formal like this:


"<RSAKeyValue>

<Modulus>1VE3SzV1Jr52rU7NOWq3ocMZF\/XghxaAMZwzIAShy0mUXHpyC1oiq1ne1V5LpHj9Z+J58f54U65lwH2tkjTe4oEY0SQH\/w\/vcpV8BcgA+QM6kbs 90yIIsoQqrkAyHHFKnbFlRAx1kI1ZKN8iVzygB4Kq0ZscdKSxaz7QbFgrY4U=

<\/Modulus>

<Exponent>AQAB<\/Exponent>

<\/RSAKeyValue>"


So I have to encrypt it with this key, I am with XCode 8 and Swift 3.


With .Net C· is very Easy.


RSACryptoServiceProvider encryptKey = new RSACryptoServiceProvider();

UnicodeEncoding encoding = new UnicodeEncoding();

encryptKey.FromXmlString(XML PublicKey);

byte[] usr = encryptKey.Encrypt(encoding.GetBytes(txtUser.Text), false);

byte[] pwd = encryptKey.Encrypt(encoding.GetBytes(txtPassword.Text), false);


¿Does any one can help me, please?


thanks

RSA Encryption with public Key
 
 
Q