日期:2014-05-18 浏览次数:20867 次
const string PUBLIC_KEY = "<RSAKeyValue><Modulus>vh4fRUXbE/SATMIqawzPhJWJiXnR1aDgeAZix pRuNyyLTSm+TjlXymWLKH4VdloUWTC1vqxR28clhOX2mdvJ........... OQhP+v55jvHxjRh8zZtt5t/DF1ZSWHuW1vZrg/9M=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"; const string PRIVATE_KEY = "<RSAKeyValue><Modulus>vh4fRUXbE/SATMIqawzPhJWJiXnR1aDgeAZ ixpRuNyyLTSm+TjlXymWLKH4VdloUWT C1vqxR28clhOX2mdvJ6CYcXq7nq2gyyzcrNhmYRpjWwHN4MKdDKoxGdnGgp30Jy1FOQhP+v55jvHxjRh8zZtt5t/DF1 ZSWHuW1vZrg/9M=</Modulus><Exponent>AQAB<.............=</D></RSAKeyValue>"; rsa.FromXmlString(PRIVATE_KEY); System.Security.Cryptography.RSAPKCS1SignatureFormatter f= new System.Security.Cryptography.RSAPKCS1SignatureFormatter(rsa); f.SetHashAlgorithm("SHA1"); Byte[] source = System.Text.ASCIIEncoding.ASCII.GetBytes(txtUser.Text); System.Security.Cryptography.SHA1Managed sha = new System.Security.Cryptography.SHA1Managed(); Byte[] result = sha.ComputeHash(source); Byte[] regkey = f.CreateSignature(result); txtCode.Text = Convert.ToBase64String(regkey); //加密ding结果为STEcJv8JNr77Ta62C+IqKR5zVhMwtpJd8CEKv6Ne6CTcJcI+Z1nRv+iTbYG+qmSr tuQJWpZFBxslRZB8grJfhT0WxEspVKJVtnzn7FRElg+Rmr1UXg8Mo7xNqLOPlTalrN3ewxnXmr6WExoJ76KW1tO2ON NoLRU2sBR0jGfUC/0=