[英]Add TimeStamp to digital signature
我有一個代碼可以在C#中成功使用A1證書對字符串進行簽名。 我需要為該簽名添加一個時間戳。 時間戳需求來自諸如http://www.cryptopro.ru/tsp/tsp.srf之類的時間戳服務器,我無法弄清楚如何將時間戳添加到簽名中。 它不是PDF符號,而是字符串符號。 有人可以幫我嗎?
用於簽名的代碼:
private byte[] Sign(string text)
{
// Find the certificate we’ll use to sign
X509Certificate2 cert = new X509Certificate2(@"C:\Users\1000084016.pfx", "Password");
RSACryptoServiceProvider csp = null;
// Get its associated CSP and private key
csp = (RSACryptoServiceProvider)cert.PrivateKey;
// Hash the data
SHA1Managed sha1 = new SHA1Managed();
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] data;
data = encoding.GetBytes(text);
byte[] hash = sha1.ComputeHash(data);
// Sign the hash
return csp.SignHash(hash, CryptoConfig.MapNameToOID("SHA1"));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.