是否可以使用 windows 表单 C# 对 .CSV 文件进行 CRC 检查
Is it possible to do CRC check for a .CSV file using windows forms C#
我正在使用 C#(Windows 窗体)构建 GUI。基本上,我的 GUI 生成一个文件(.CSV 格式)。
例如,假设我的 GUI 生成了以下 .csv 文件。
Username, Password, MachineID
abc, abc, 123
jkl, jkl, 789
rst, rst, 456
现在我将实现一项功能,我的 GUI 应该回读上面生成的文件,在回读时我想验证该文件,因为在读取该 .csv 文件并将其内容显示到我的 GUI 之前,我想要验证用户是否手动更改了文件内容。
以后我只是看看有没有CRC校验方法来验证文件?或者请建议我任何其他方法 validate/to 查找用户是否手动修改了文件?
得到这个class
然后像这样使用它
DamienG.Security.Cryptography.Crc32 crc32 = new DamienG.Security.Cryptography.Crc32();
String CSVCrc32hash = String.Empty;
foreach (byte b in crc32.ComputeHash(**here your csv file bytes in byte[] format**))
{
CSVCrc32hash += b.ToString("x2").ToLower();
}
//the CSVCrc32hash is the hash
我正在使用 C#(Windows 窗体)构建 GUI。基本上,我的 GUI 生成一个文件(.CSV 格式)。
例如,假设我的 GUI 生成了以下 .csv 文件。
Username, Password, MachineID
abc, abc, 123
jkl, jkl, 789
rst, rst, 456
现在我将实现一项功能,我的 GUI 应该回读上面生成的文件,在回读时我想验证该文件,因为在读取该 .csv 文件并将其内容显示到我的 GUI 之前,我想要验证用户是否手动更改了文件内容。
以后我只是看看有没有CRC校验方法来验证文件?或者请建议我任何其他方法 validate/to 查找用户是否手动修改了文件?
得到这个class
然后像这样使用它
DamienG.Security.Cryptography.Crc32 crc32 = new DamienG.Security.Cryptography.Crc32();
String CSVCrc32hash = String.Empty;
foreach (byte b in crc32.ComputeHash(**here your csv file bytes in byte[] format**))
{
CSVCrc32hash += b.ToString("x2").ToLower();
}
//the CSVCrc32hash is the hash