请告诉我通过一个asp.net根据网站
Whats the best way to digitally sign a file server side with .Net before offering it for download via an asp.net based web site
在另外我如何触发检查签名的,因此证明在下载过程中在网络浏览器尚未tmapered与文件
In addition how do I trigger checking of the signature and hence prove the file has not been tmapered with during the download process in a web browser
一个签名不需要被包含在ZIP文件,也可以是一个独立的签名。所以,你可以有拉链,让别人来验证签名,这通常只是由一系列十六进制或Base64字符,带外与你编写一个应用程序。
A signature does not need to be included with the ZIP file, it can be a "detached" signature. So you could have the zip and allow someone to verify the sig, which is usually just a series of hex or base64 characters, out of band with an app you write.
目前的高级别,签名的步骤是:
At a high-level, the signing steps are:
AsymmetricAlgorithm privateKey = certificate.PrivateKey;
byte[] buffer = Encoding.Default.GetBytes(<data from the zip>);
byte[] signature = privateKey.SignData(buffer, new SHA1Managed());
和验证:
RSACryptoServiceProvider publicKey = certificate.PublicKey.Key as RSACryptoServiceProvider;
bool verify = publicKey.VerifyData(buffer, new SHA1Managed(), signature);