public static string Sign(string myString)
{
X509Certificate2 cert = new X509Certificate2(@"xxxxx.pfx", "123456");
CmsSigner signer = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, cert);
signer.DigestAlgorithm = new Oid(Oids.Sha1);
ContentInfo content = new ContentInfo(new Oid(Oids.Pkcs7Data), Encoding.UTF8.GetBytes(myString));
SignedCms signedCms = new SignedCms(content, true);
signedCms.ComputeSignature(signer, false);
var asig = signedCms.Encode();
return Convert.ToBase64String(asig);
}
标签:pkcs,12,ContentInfo,signedCms,sign,SignedCms,signer,new,net
From: https://www.cnblogs.com/springhgui/p/16596765.html