首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加密HttpPostedFileBase

加密HttpPostedFileBase
EN

Stack Overflow用户
提问于 2014-01-15 20:02:13
回答 1查看 724关注 0票数 1

我正在开发一个asp mvc #应用程序。我想加密一个HttpPostedFileBase (下面的代码中的file是我想加密的HttpPostedFileBase ):

代码语言:javascript
复制
void Upload(string target, HttpPostedFileBase file)
{
FullPath dest = ParsePath(target);
FileInfo path = new FileInfo(Path.Combine(dest.Directory.FullName, Path.GetFileName(file.FileName)));

//file.SaveAs(path.FullName);

MemoryStream _MemoryStream = new MemoryStream();
file.InputStream.CopyTo(_MemoryStream);

DESCryptoServiceProvider cryptic = new DESCryptoServiceProvider();

cryptic.Key = ASCIIEncoding.ASCII.GetBytes("ABCDEFGH");
cryptic.IV = ASCIIEncoding.ASCII.GetBytes("ABCDEFGH");

CryptoStream crStream = new CryptoStream(_MemoryStream, cryptic.CreateEncryptor(), CryptoStreamMode.Write);
//Here I want to save my crypted stream to the path
//....
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-15 22:10:53

代码语言:javascript
复制
    CryptoStream crStream = new CryptoStream(_MemoryStream, cryptic.CreateEncryptor(), CryptoStreamMode.Write);
    using (var output = new FileStream(path.FullName, FileMode.Create, FileAccess.Write))
    {
        crStream.CopyTo(output);
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21147073

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档