下面的代码是117个a,再多一个a,就会报错。。。
而MSDN上的解释是说128字符...感谢大牛们参与
- C# code
protected void Page_Load(object sender, EventArgs e){ RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); string pwd = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaa"; int a = Encoding.ASCII.GetBytes(pwd).Length; //int length = Encoding.Unicode.GetBytes(pwd).Length; byte[] Bytes = rsa.Encrypt(Encoding.ASCII.GetBytes(pwd), false);}
------解决方案--------------------------------------------------------
刚调试了一下,当pwd是117个a的时候,发现GetBytes(pwd)是128个字节。