如何在c#.net文件创建过程中加密文件中的数据? [英] How to encrypt data in file during file creation in c# .net?

查看:93
本文介绍了如何在c#.net文件创建过程中加密文件中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想使用c#加密文件数据,我使用此代码我的文件没有加密。

我的代码: -

FileStream fs1 = new FileStream(D:\\Licence.DAT,FileMode.OpenOrCreate,FileAccess.Write);

File.SetAttributes (D:\\Licence.DAT,FileAttributes.Encrypted);

StreamWriter writer = new StreamWriter(fs1);

writer.Write(Validated Days :++ txtValidatedDays.Text);

writer.WriteLine(\ n+MAC地址:++ txtMacAddress.Text);

writer.Close();



MessageBox.Show(许可证生成成功);



请帮帮我。



先谢谢。



Ankit Agarwal

软件工程师

Hello,

I want to encrypt data of file using c#,I am using this code my file it's not encrypting.
My code:-
FileStream fs1 = new FileStream("D:\\Licence.DAT", FileMode.OpenOrCreate, FileAccess.Write);
File.SetAttributes("D:\\Licence.DAT", FileAttributes.Encrypted);
StreamWriter writer = new StreamWriter(fs1);
writer.Write("Validated Days:" + "" + txtValidatedDays.Text);
writer.WriteLine("\n" + "MAC Address:" + "" + txtMacAddress.Text);
writer.Close();

MessageBox.Show("Licence Generated Successfully");

Please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer

推荐答案

不加密它:你需要每次敌人比较时都提供一个解密密钥。

相反,使用散列函数并比较输出。

MSDN:SHA512 [ ^ ]



您知道欺骗MAC地址 [ ^ ],不是吗?
Don't encrypt it: you need to provide a key to decrypt it each time foe comparison.
Instead, use a hashing function and compare the outputs instead.
MSDN: SHA512[^]

And you are aware of just how easy it is to "spoof" a MAC address[^], aren't you?


这篇关于如何在c#.net文件创建过程中加密文件中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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