troubleshooting Question

Changing a value in an encrypted file using VBA

Avatar of Tracy
TracyFlag for United States of America asked on
Microsoft ExcelMicrosoft ApplicationsMicrosoft Office
7 Comments1 Solution484 ViewsLast Modified:
I'm trying to replace a value in an encrypted file.  We changed servers, so the new server name needs to be added to the encrypted ini file.

This temporary fix works, but it defeats the purpose of the encrypted file if you enter the data directly into the code:
Public Property Get Server() As String
    'Work around
    'Server = "PEFSSQL01" ''Hard coded server name change. Change made on 5-11-11
   
   'Original code
   Server = DecryptString(msSvrNm, msCrypKey, True)
End Property

This code works (decryptStringCode), it produces the correct result with the hex encryption value given.  The correct result is PEFSSQL01.  However, when I copy this hex string into the ini file and then run the checkServerName procedure, it does not produce the correct result.

So what I need is to replace the hex string between the <s> </s> tags in the ini file and have the result of the checkServerName equaled to PEFSSQL01.

I've stripped out some of the values in the encrypted file.  Attached is the workbook with the class module and regular module where I'm testing.  The ini file should be saved in a folder called 'cfg'.  The 'cfg' folder should be in the same directory where you save the workbook.

Thanks in advance for the help, I've been trying for a day now to figure this out.

Tracy
Sub decryptStringCode()
   
   Dim clsX As cls_Cfg
    
    Set clsX = New cls_Cfg

    '****************************************
    'This produces the result: PEFSSQL01
    Debug.Print clsX.DecryptString("EB29DEABBF877B585F6FBB29F987B913545771F67D68C092", "L0c@lKeyKrypt", True)
    '****************************************

    Set clsX = Nothing
 
End Sub

Open in new window

Sub checkServerName()

    Dim clsX As cls_Cfg
    
    Set clsX = New cls_Cfg

    MsgBox "Server Name: " & clsX.Server 'Does not show correct result of PEFSSQL01
    MsgBox "User Name: " & clsX.User 'Shows correct result

    Set clsX = Nothing

End Sub

Open in new window

pemirr.ini
Book1.xlsm
ASKER CERTIFIED SOLUTION
Arno Koster
Software designer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros