如何将文本文件的内容添加到哈希表? [英] How do I add contents of text file to hashtable?

查看:117
本文介绍了如何将文本文件的内容添加到哈希表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对哈希表的功能感到困惑.我想将我的txt文件的内容添加到哈希表中. txt文件的内容是MD5哈希,即使它似乎可以正常工作,也存在一些已知的病毒文件,例如eicar测试文件,由于某种原因,该文件不再被检测到.

这是我到目前为止编写的代码

I am confused about the functions of the hash table. I would like to add the contents of my txt file to the hash table. The contents of the txt file is MD5 hashes and even though it seems to be working there are some known virus files such as the eicar test file which is no longer detected for some reason.

this is the code I have wrote so far

Dim Hashdatabase As New Hashtable
Dim md5Compare As New TextBox
Dim md5textload as new textbox
Dim labelX12 As New Label
Dim labelX13 As New Label

MD5Textload.text = my.computer.filesystem.readalltext("Sig.txt")
Hashdatabase.Contains(MD5Textload.Text)
md5Compare.Text = Hashdatabase.Values.ToString

Try
            With My.Computer.FileSystem
                If stop_Scan = True Then
                    Exit Sub
                End If
                For Each file1 In System.IO.Directory.GetFiles(dir)
                    Dim fs As New FileInfo(file1)
                    labelX12.Text = getMd5Hash(fs.FullName)
                    labelX13.Text = getSHA1Hash(fs.FullName)
                    If md5Compare.Text.Contains(labelX12.Text) Then
                        CheckedListBox1.Items.Add(fs.FullName)
                        CheckedListBox1.Text = "!!Attention Infection(s) Found!!"
                        lblvirus.Text = CheckedListBox1.Items.Count






有人可以告诉我是否将文本文件错误地添加到哈希表中吗?如果是的话,我该如何做才能使其起作用?






Can someone please tell me if I am adding the text file to hashtable incorrectly? if so how can I do this so that it works?

推荐答案

您正在将两个不同的主题混淆在一起:

1. HashTables在内存数据结构中而不是基于文件的.

2. MD5加密哈希函数根据函数的输入来计算结果


我想您想创建一个病毒检查系统"来检测文件的更改.

1.您需要基于磁盘的存储来存储文件名和md5哈希结果,因为您无法将它们全部保留在内存中,并且每次都要遍历它们都是很耗时的.

2.您需要一种从该存储系统提取数据的最佳方法.

为此,请检查我的 RaptorDB 代码,因为它是基于磁盘的哈希存储系统
You are confusing two different topics together:

1. HashTables are in memory data structures not file based.

2. MD5 cryptographic hash functions compute a result based on the input to the function


I presume you want to create a "virus checking system" to detect changes to files.

1. You need disk based storage for the filename and md5 hash results as you cannot keep them all in memory and it would be time consuming to go through them all every time.

2. You need an optimal way of extracting data from that storage system.

For this check my RaptorDB code as it is a disk based hash storage system


这篇关于如何将文本文件的内容添加到哈希表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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