Hi,
Not sure if this is the right area, but I'm trying to write some code to open/read from an encrypted text file. So far I have:
Option Explicit
'File Stream Objects
Private objFSO As Object
Private objPasswordFile As Object
'Strings
Public strAdminPassword As String
Private Const strFilePath As String = "My Dir"
Public Sub GetAdminPassword()
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFilePath) Then
Set objPasswordFile = objFSO.OpenTextFile(strFilePath, 1)
strAdminPassword = objPasswordFile.ReadLine
objPasswordFile.Close
Else
MsgBox "File Error", vbOKOnly, "Error"
End
End If
Set objFSO = Nothing
Set objPasswordFile = Nothing
End Sub
This code works fine since the only line/item in the file is the password, but now I'd like to add some encryption to this ... I'm wondering if someone can assist with a link or something since I'm unable to find anything related to this.
The reason for this is unfortunately we have many separate macros (sage VBA) which require the admin login and password and we've had to hardcode this in hundreds of spots and I'm trying to build a deployment structure so the file can be overwritten as need to change the password and remove the hardcoding from the macro, but the users would have access to the file location as well so we can't have them opening it and seeing the admin password.
Not sure if this is the right area, but I'm trying to write some code to open/read from an encrypted text file. So far I have:
Option Explicit
'File Stream Objects
Private objFSO As Object
Private objPasswordFile As Object
'Strings
Public strAdminPassword As String
Private Const strFilePath As String = "My Dir"
Public Sub GetAdminPassword()
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFilePath) Then
Set objPasswordFile = objFSO.OpenTextFile(strFilePath, 1)
strAdminPassword = objPasswordFile.ReadLine
objPasswordFile.Close
Else
MsgBox "File Error", vbOKOnly, "Error"
End
End If
Set objFSO = Nothing
Set objPasswordFile = Nothing
End Sub
This code works fine since the only line/item in the file is the password, but now I'd like to add some encryption to this ... I'm wondering if someone can assist with a link or something since I'm unable to find anything related to this.
The reason for this is unfortunately we have many separate macros (sage VBA) which require the admin login and password and we've had to hardcode this in hundreds of spots and I'm trying to build a deployment structure so the file can be overwritten as need to change the password and remove the hardcoding from the macro, but the users would have access to the file location as well so we can't have them opening it and seeing the admin password.