C# Windows Phone 8上的X509Certificate2到X509Certificate
我需要让下面的代码在WP8上工作,问题是WP8上没有X509Certificate2类,我尝试过使用bouncy castle API,但我还没有真正解决这个问题 有没有办法让这段代码在WP8上工作C# Windows Phone 8上的X509Certificate2到X509Certificate,c#,windows-phone-7,encryption,windows-phone-8,windows-phone,C#,Windows Phone 7,Encryption,Windows Phone 8,Windows Phone,我需要让下面的代码在WP8上工作,问题是WP8上没有X509Certificate2类,我尝试过使用bouncy castle API,但我还没有真正解决这个问题 有没有办法让这段代码在WP8上工作 private string InitAuth(X509Certificate2 certificate, string systemId, string username, string password) { byte[] plainBytes = Encodi
private string InitAuth(X509Certificate2 certificate, string systemId, string username, string password)
{
byte[] plainBytes = Encoding.UTF8.GetBytes(password);
var cipherB64 = string.Empty;
using (var rsa = (RSACryptoServiceProvider)certificate.PublicKey.Key)
cipherB64 = systemId + "^" + username + "^" + Convert.ToBase64String(rsa.Encrypt(plainBytes, true));
return cipherB64;
}
难道您不能绕过
X509Certificate2
的可用性吗
private string InitAuth(X509Certificate certificate, string systemId, string username, string password)
{
byte[] plainBytes = Encoding.UTF8.GetBytes(password);
var cipherB64 = string.Empty;
//Create a new instance of RSACryptoServiceProvider.
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
//Create a new instance of RSAParameters.
RSAParameters RSAKeyInfo = new RSAParameters();
//Set RSAKeyInfo to the public key values.
RSAKeyInfo.Modulus = certificate.getPublicKey();
RSAKeyInfo.Exponent = new byte[3] {1,0,1};;
//Import key parameters into RSA.
RSA.ImportParameters(RSAKeyInfo);
using (RSA)
cipherB64 = systemId + "^" + username + "^" + Convert.ToBase64String(RSA.Encrypt(plainBytes, true));
return cipherB64;
}
披露:我没有尝试上面的代码,因为我目前没有一个C#运行时环境供我使用。@MaryJ。你看了吗?没有,对不起,我没有时间看。请回答这个问题@likeitlikeit