我正在开发一个反恶意软件,想要从Signature.txt文件中读取Signature,并将所有字符串放入不同的文本框中,我的病毒列表中有90069500个恶意软件(几乎收集了一年)签名,如果我开始打字,那就像:
If buff.ToString = "000008298FC27014ECF5610F163277E2" Then
txtvirname.Text = "Trojan-GameThief.Win32.OnLineGames.tvl"
txtrisk.Text = "Moderate"
txtrisk.ForeColor = Color.Yellow
txtfinger.Text = "Delete :: Permanently""
有没有办法在列表的行中找到MD5哈希(如:“000008298FC27014ECF5610F163277E2”),然后拆分该行并将哈希,名称,首选操作和风险放入单独的文本框中
答案 0 :(得分:0)
如果使所有线条的长度相同,则可以计算每条线的起始位置。通过哈希对行进行排序,然后您可以在文件中进行二进制搜索而不加载它。使用Seek
类的FileStream
方法来读取文件中的随机位置。
修改强>: 假设100个字节用于存储一行,则此代码访问特定行:
Public Function GetLine(lineNo As Integer, stream As FileStream) As String
Const LineLength As Integer = 100 ' Including CR/LF
Dim bytes As Byte() = New Byte(LineLength-1);
stream.Seek(lineNo * LineLength, SeekOrigin.Begin) ' Line number assumed zero based.
Dim bytesRead = stream.Read(bytes, 0, LineLength)
' For simplicity, I assume that the file is ASCII encoded, other encodings might
' use two bytes per character or even a variable length.
Return Encoding.ASCII.GetString(bytes)
End Function
请参阅此处查看Binary Search Algorithm。