我有一个纯文本的自定义设置文件,读取该文件,然后每行代表变量设置。以下是文件包含的内容
在线 19X.13X.XX.1XX 地点 规范 关口 存储路径
我可以加密文件并将其放在用户计算机上,我不希望他们对此进行任何更改或阅读文件上的内容
我可以将文件解密回光盘,但我不想这样,我需要的是仅在内存中使用这些值。
这是我必须回写解密文件(我在网上找到的东西)
Public Function Decrypt(ByVal B() As Byte, ByVal PSW As String) As Byte()
' generates a key from the password
Dim pdb As System.Security.Cryptography.PasswordDeriveBytes = New System.Security.Cryptography.PasswordDeriveBytes(PSW, New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
' this holds the encrypted
Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream()
' this object holds the information about the AES encryption
Dim AESE As System.Security.Cryptography.Aes = New System.Security.Cryptography.AesManaged()
AESE.Key = pdb.GetBytes(AESE.KeySize / 8)
AESE.IV = pdb.GetBytes(AESE.BlockSize / 8)
' decrypt the data
Dim cs As System.Security.Cryptography.CryptoStream = New System.Security.Cryptography.CryptoStream(ms, AESE.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Write)
cs.Write(B, 0, B.Length)
cs.Close()
Return ms.ToArray()
End Function
我需要帮助来阅读每一行并将其分配给变量。 提前谢谢