static string Decrypt(string data)
{
X509Certificate2 myCertificate = new X509Certificate2("c:\\temp
RSACryptoServiceProvider provider1 = (RSACryptoServiceProvider)
byte[] buffer1 = Convert.FromBase64String(d
byte[] result = provider1.Decrypt(buffer1,
return Encoding.UTF8.GetString(result);
//return (new UnicodeEncoding()).GetString(result);
}
static string Encrypt(string data)
{
X509Certificate2 myCertificate = new X509Certificate2("c:\\temp\\mycerts.p12", "123456");
RSACryptoServiceProvider provider1 = (RSACryptoServiceProvider)myCertificate.PublicKey.Key;
//byte[] buffer1 = (new UnicodeEncoding()).GetBytes(data);
//return (new UnicodeEncoding()).GetStri
}
static string Encrypt(string data)
{
X509Certificate2 myCertificate = new X509Certificate2("c:\\temp
RSACryptoServiceProvider provider1 = (RSACryptoServiceProvider)
//byte[] buffer1 = (new UnicodeEncoding()).GetByte
byte[] buffer1 = Encoding.UTF8.GetBytes(data);
byte[] result = provider1.Encrypt(buffer1, false);
string b64s = Convert.ToBase64String(result);
return b64s;
}
static bool VerifyData(string data, string signature)
{
X509Certificate2 myCertificate = new X509Certificate2("c:\\temp\\mycerts.p12", "123456");
RSACryptoServiceProvider provider1 = (RSACryptoServiceProvider)myCertificate.PublicKey.Key;
byte[] sb = Convert.FromBase64String(signature);
), sb);
}
static string SignData(string data)
{
X509Certificate2 myCertificate = new X509Certificate2("c:\\temp\\mycerts.p12", "123456");
RSACryptoServiceProvider provider1 = (RSACryptoServiceProvider)myCertificate.PrivateKey;
//byte[] db = (new ASCIIEncoding()).GetBytes(data);
byte[] result = provider1.Encrypt(buffer1,
string b64s = Convert.ToBase64String(res
return b64s;
}
static bool VerifyData(string data, string signature)
{
X509Certificate2 myCertificate = new X509Certificate2("c:\\temp
RSACryptoServiceProvider provider1 = (RSACryptoServiceProvider)
byte[] sb = Convert.FromBase64String(s
//byte[] db = (new ASCIIEncoding()).GetBytes(data);
byte[] db = Encoding.UTF8.GetBytes(data);
return provider1.VerifyData(db, new SHA1CryptoServiceProvider(}
static string SignData(string data)
{
X509Certificate2 myCertificate = new X509Certificate2("c:\\temp
RSACryptoServiceProvider provider1 = (RSACryptoServiceProvider)
//byte[] db = (new ASCIIEncoding()).GetBytes(data);
byte[] db = Encoding.UTF8.GetBytes(data);
byte[] sb = provider1.SignData(db, new SHA1CryptoServiceProvider(return Convert.ToBase64String(sb)
}
沒有留言:
張貼留言