我正在尝试将文本文件转换为base64,并将其哈希为MD5。问题是我不知道该怎么做。我尝试查看Google的示例。我目前正在使用this一个。
但是在检查了代码之后,我只是注意到它转换了字符串,文本文件的文件路径,而不是文本文件本身。我知道在此站点上寻求帮助不是一种好习惯,但是我真的不知道该怎么做,有人可以在我使用要更改的代码上向我指出吗?
我将尝试帮助您打开涉及.txt文件的部分,复制其内容并将加密后的字符串保存在新文件中。没有时间测试加密部分,但您已经确认它可以工作...
Sub testOpenEncryptSave()
Dim objFSO As Object, fullFilename As String
Dim objTF As Object
Dim strIn As String
'Open your unencripted file and load its content in variable "strIn"___:
fullFilename = "YourFileToEncript Full Name"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTF = objFSO.OpenTextFile(fullFilename, 1)
strIn = objTF.ReadAll
objTF.Close
'______________________________________________________________________
'Do here the encryption of strIn:
Dim strEncr As String
strEncr = FileToMD5(strIn) 'you must have in the same module or in a
'different one the code which you use now
'______________________________________________________________________
'Save the encrypted string in the new file:_____________________
Dim Fileout As Object, encrFilePath As String
encrFilePath = "YourEncryptedFile Full Name"
Set Fileout = objFSO.CreateTextFile(encrFilePath, True, True)
Fileout.Write strEncr
Fileout.Close
'_______________________________________________________________
MsgBox "Done..."
End Sub
请注意使用真实路径更改路径(“ YourFileToEncript全名”和“ YourEncryptedFile全名” ...请确认它可以正常工作。