Option Compare Database

Function EncryptOrDecrypt(strEncryptOrDecrypt As String, strValue As String) As String
'Encrypt or decrypt a string using SmackoCrypt
On Error GoTo Fn_Error
    Dim objShell As Object, strCommandLine As String
    Dim objExecute As Object, objOutput As Object
    Dim strArgs As Variant
    Dim strReturn As String, strLine As String
    Set objShell = CreateObject("WScript.Shell")
    strArgs = Chr(34) & strEncryptOrDecrypt & Chr(34) & " " & Chr(34) & strValue & Chr(34)
    strCommandLine = "C:\dev\SmackoCrypt.exe" & " " & strArgs
    Set objExecute = objShell.Exec(strCommandLine)
    Set objOutput = objExecute.StdOut
    While Not objOutput.AtEndOfStream
        strLine = objOutput.ReadLine
        If strLine <> "" Then strReturn = strReturn & strLine & vbNewLine
    Wend
    Set objOutput = Nothing: Set objExecute = Nothing
    Set objShell = Nothing
Fn_Exit:
If Right(strReturn, 2) = vbCrLf Then strReturn = Left(strReturn, Len(strReturn) - 2)
EncryptOrDecrypt = strReturn
Exit Function
Fn_Error:
    MsgBox "There was an error. (" & Err & ")  " & Error
    Resume Fn_Exit
End Function

