文件内容没有得到加密asp.net [英] file content not getting encrypt asp.net

查看:79
本文介绍了文件内容没有得到加密asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我加密我的文件头只加密。我的文件中的内容没有加密。

when I encrypt my file header only getting encrypted. what ever the content in my file not getting encrypted.

string uploadedFilePath = @"E:\New Folder\";
FileUpload1.SaveAs(uploadedFilePath + Encrypt(FileUpload1.FileName));

public static string Encrypt(string input)
{
  byte[] inputArray = UTF8Encoding.UTF8.GetBytes(input);
  TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
           
  ICryptoTransform cTransform = tripleDES.CreateEncryptor();
  byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length);
  tripleDES.Clear();
  return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}

推荐答案

您只加密文件名 FileUpload1.SaveAs(uploadedFilePath + Encrypt(FileUpload1) .FileName)); 。要加密整个文件,您需要加密文件内容(不仅是名称)。



Nathan Blomquist写了一篇关于此的文章:

使用C#中的散列验证进行文件加密/解密 [ ^ ]
You are encrypting the filename only FileUpload1.SaveAs(uploadedFilePath + Encrypt(FileUpload1.FileName));. To encrypt the whole file you need to encrypt the file content (not only the name).

Nathan Blomquist have written an article about this:
File Encryption/Decryption with Hash Verification in C#[^]


这篇关于文件内容没有得到加密asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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