我最近发布了有关使用RSA加密大数据的问题,我最终完成了这一点,现在我继续使用用户的私钥实现签名并使用相应的公钥进行验证.但是,每当我比较签名数据和原始消息时,我基本上只会返回false.我希望你的一些人能看出我做错了什么.
这是代码:
public static string SignData(string message, RSAParameters privateKey)
{
//// The array to store the signed message in bytes
byte[] signedBytes;
using (var rsa = new RSACryptoServiceProvider())
{
//// Write the message to a byte array using UTF8 as the encoding.
var encoder = new UTF8Encoding();
byte[] originalData = encoder.GetBytes(message);
try
{
//// Import the private key used for signing the message
rsa.ImportParameters(privateKey);
//// Sign the data, using SHA512 as the hashing algorithm
signedBytes = rsa.SignData(originalData, CryptoConfig.MapNameToOID("SHA512"));
}
catch …
Run Code Online (Sandbox Code Playgroud)