RSA algorithm is producing different output value on different .NET framework. The encrypted password with .NET 3.5 framework has "==" at end but with .NET 4.6.2 the encrypted password has only one "=" at end.
Password = "abc123" output generate on .NET 3.5
vsJJq67cZaS89DMI1BtPDxiWrnNZykqAgJTLUv4un/Zs1acZbaQ8P/kiahC2ZXEsT+d/2JtYxlDiUr63gaR4QGPEAowBadiE7FfThBVeRyNU6O5vc/ptW+wenp3K9ScMy9ZLyPCp9Sp6zoLxFohBKk/RK0mW9YHH/KgEoQsVVeDLFjnWm/svZynCHJjPmG1uaBSP5B4+SStkZNJidhIm7sv0vf9Inb0N1gl4xlq8GtXEgWuQS5SwS+oa4yJNMr9zGPnpagVAXJZbVKFA04xRmU7O7Szl4Cska4oXpVJyhDL304UbvH3Q/2FYmnZ7gLcmbxIqcmr/4jfDs/MixLYrBQ==
Password = "abc123" output generate on .NET 4.6.2
AF2oLOsFQJnMEC3B7iJ5HPBAtWfoTDUXAK8FcOIv2vjc7G0VTUo3qOtF2bBrbpcABhUY5+IifZHOIgWQB1umGcGCsPs3i2pYLrP3c1uhCycE9GNvn9VywUZPD4XsnZrJcPuuV9QS5nDgf6/xIX5PVdAFuFLEceL+yEr19dhi6o+kBGx88boKDPMBQB+r3zJSK1fBZ6p3zvOmUTjxZ4RAxOiyLHdM7MineeyYCsmkd5x7O6BKc37tLSgQWVSUcpT25ib8T1/F794zP8IV2LHw7fZA8QRF7WftLHsPZl2HJegfclKEyOjIVqZe8Qup9dhmSBxM5Jb1U1nGlTDapYe3+C0=
Scenario: I am sending the encrypted password to third party for verification but the they failed to decrypte the encrypted password generated by .NET 4.6.2 framework, but they are getting password after decryption of encrypted password generated by .NET 3.5 framework.
My code for encryption is
public string Encryption(string strText)
{
var testData = Encoding.UTF8.GetBytes(strText);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(publicKey.ToString());
var encryptedData = rsa.Encrypt(testData, false);
return Convert.ToBase64String(encryptedData);
}
My Approach to cater this issue right now
I am writing the encrypted password generated by .NET 3.5 framework into file and read the output from the file in .NET 4.6.2 framework.
My approach looks not right solution because when the customers load will increase for password verification the CPU usage will be very high that will affect the system performance.
Please guide me how to cater this problem with right approach or my approach is right ?