请告诉我最好的方式进行数字签名使用.NET下载一个zip文件 [英] Whats the best way digitally sign a zip file for download using .Net

查看:101
本文介绍了请告诉我最好的方式进行数字签名使用.NET下载一个zip文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我通过一个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);

这篇关于请告诉我最好的方式进行数字签名使用.NET下载一个zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆