RSA签名算法实现
发布日期:2022/11/16 作者:
浏览:847
// Create message and signature on your end string message = "Here is the license message"; var converter = new ASCIIEncoding(); byte[] plainText = converter.GetBytes(message); var rsaWrite = new RSACryptoServiceProvider(); var privateParams = rsaWrite.ExportParameters(true); // Generate the public key / these can be sent to the user. var publicParams = rsaWrite.ExportParameters(false); byte[] signature = rsaWrite.SignData(plainText, SHA1.Create()); // Verify from the user's side. Note that only the public parameters // are needed. var rsaRead = new RSACryptoServiceProvider(); rsaRead.ImportParameters(publicParams); if (rsaRead.VerifyData(plainText, SHA1.Create(), signature)) { Console.WriteLine("Verified!"); } else { Console.WriteLine("NOT verified!"); }
下拉加载更多评论