Sign in to follow this  
Followers 0
Klexen

Need some help with _StringEncrypt, making password hidden.

3 posts in this topic

I've been trying to get 2 things working on my program. One to get my password fields hidden with * and having the program write the password to the inifile as encrypted. Then for my program to be able to read it. My head hurts from trying, I was wondering if can get some help with that?

Func _InputBoxM($title, $message, _
        $label_0, $input_0, _
        $label_1= '', $input_1= '', _
        $label_2= '', $input_2 = '', _
        $label_3= '', $input_3 = '', _
        $label_4= '', $input_4 = '', _
        $label_5= '', $input_5 = '', _
        $label_6= '', $input_6 = '', _
        $label_7= '', $input_7 = '', _
        $label_8= '', $input_8 = '', _
        $label_9= '', $input_9 = '', _
        $label_10= '', $input_10 = '' _
    )
    
    
    If Mod(@NumParams - 2,2)<>0 Then
        MsgBox(0x10,"Error","Incorrect number of parameters!")
        Return -2
    EndIf
    
    Local $width = 300
    Local $i_UBound = (@NumParams - 2)/2
    Local $input[$i_UBound]
    Local $label[$i_UBound]
    Local $result[$i_UBound]
    If $title = '' then Return -2
    If $message = '' then Return -2
    If $label_0 = '' then Return -2
        
    $guiOnEvent = Opt('GUIOnEventMode', 0)
    
    $optionGui = GuiCreate($title, $width, 100 + ((@NumParams - 2)/2) * 45, -1, -1, $DS_SETFOREGROUND)
    
    GuiCtrlCreateLabel($message, 5, 5, $width - 10, 30, $SS_CENTER)
    
    For $i_Index = 0 To $i_UBound - 1
        
        $label[$i_Index] = GUICtrlCreateLabel(Eval("label_" & String($i_Index)), 5, 40+ $i_Index * 45, 285)
        $input[$i_Index] = GUICtrlCreateInput(Eval("input_" & String($i_Index)), 5, 40+ $i_Index * 45+20, 285)
    Next
    
    $ok = GuiCtrlCreateButton('OK', $width / 2 - 90, ($i_UBound) * 45 + 45, 80, 25)
    $cancel = GuiCtrlCreateButton('Cancel', $width / 2 + 10, ($i_UBound) * 45 + 45, 80, 25)
    
    GuiSetState()
    
    While 1
        Switch GuiGetMsg()
            Case $GUI_EVENT_CLOSE
                Exitloop
            Case $cancel
                Exitloop
            Case $ok
                For $a = 0 to $i_UBound - 1
                        $result[$a]=GUICtrlRead($input[$a])
                Next
                ExitLoop
        EndSwitch
    WEnd
    
    GuiDelete()
    Opt('GUIOnEventMode', $guiOnEvent)
    Return $result
EndFuncoÝ÷ Ù«­¢+ÙÕ¹
ÉÑ1½¥¸ ¤(ì´´´´µ
Éѱ±MÉØ1½¥¸´´´´´´(ÀÌØíµ±±ÍÉÙÁÍÌô}%¹ÁÕÑ ½á4 ÅÕ½Ðí±±MÉØ1½¥¸ÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈå½Õȱ±MÉØ1½¥¸%¹¼ÅÕ½Ðì°ÅÕ½Ðí±±MÉØUÍÈ%ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí±±MÉØAÍÍݽÉÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí±±MÉØ    %ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤()%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½Ðí±±MÉÙ1½¥¸ÅÕ½Ðì°ÅÕ½Ðí±±ÍÉÙ¥ÅÕ½Ðì°ÀÌØíµ±±ÍÉÙÁÍÍlÁt¤)%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½Ðí±±MÉÙ1½¥¸ÅÕ½Ðì°ÅÕ½Ðí±±ÍÉÙÁÍÌÅÕ½Ðì°ÀÌØíµ±±ÍÉÙÁÍÍlÅt¤)%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½Ðí±±MÉÙ1½¥¸ÅÕ½Ðì°ÅÕ½Ðí±±ÍÉÙÅÕ½Ðì°ÀÌØíµ±±ÍÉÙÁÍÍlÉt¤(((ì´´´´µ
ÉÑ
¥ÑÉ¥à1½¥¸´´´´´´(ÀÌØíµ
¥ÑÉ¥áÁÍÌô}%¹ÁÕÑ    ½á4 ÅÕ½Ðí
¥ÑÉ¥à1½¥¸ÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈå½ÕÈ
¥ÑÉ¥à1½¥¸%¹¼ÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈUÍÈ9µÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈAÍÍݽÉÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤()%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½Ðí
¥ÑÉ¥á1½¥¸ÅÕ½Ðì°ÅÕ½Ðí
¥ÑÉ¥áÕÍÈÅÕ½Ðì°ÀÌØíµ
¥ÑÉ¥áÁÍÍlÁt¤)%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½Ðí
¥ÑÉ¥á1½¥¸ÅÕ½Ðì°ÅÕ½Ðí
¥ÑÉ¥áÁÍÌÅÕ½Ðì°ÀÌØíµ
¥ÑÉ¥áÁÍÍlÅt¤(((ì´´´´µ
Éѱ°
½¹¹Ð1½¥¸´´´´´´(ÀÌØíµM
ÁÍÌô}%¹ÁÕÑ  ½á4 ÅÕ½Ðí±°
½¹¹Ð1½¥¸ÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈå½Õȱ°
½¹¹Ð1½¥¸%¹¼ÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈUÍÈ9µÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈAÍÍݽÉÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤()%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½Ðí±±
½¹¹ÐÅÕ½Ðì°ÅÕ½Ðí±±
½¹¹ÑUÍÈÅÕ½Ðì°ÀÌØíµM
ÁÍÍlÁt¤)%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½Ðí±±
½¹¹ÐÅÕ½Ðì°ÅÕ½Ðí±±
½¹¹ÑAÍÌÅÕ½Ðì°ÀÌØíµM
ÁÍÍlÅt¤((ì´´´´µ
ÉÑÑ¥µ1½¥¸´´´´´(ÀÌØíµÑ¥µÁÍÌô}%¹ÁÕÑ  ½á4 ÅÕ½ÐíÑ¥µ1½¥¸ÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈå½ÕÈÑ¥µ1½¥¸%¹¼ÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈUÍÈ9µÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíA±Í¹ÑÈAÍÍݽÉÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤()%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½ÐíÑ¥µÅÕ½Ðì°ÅÕ½ÐíÑ¥µUÍÈÅÕ½Ðì°ÀÌØíµÑ¥µÁÍÍlÁt¤)%¹¥]É¥Ñ ÀÌØí¥±}1½Ñ¥½¸°ÅÕ½ÐíÑ¥µÅÕ½Ðì°ÅÕ½ÐíÑ¥µAÍÌÅÕ½Ðì°ÀÌØíµÑ¥µÁÍÍlÅt¤()¹Õ¹ìôôÐí
ÉÑ1½¥¸

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstants.au3>
#include <String.au3>

Func _InputBoxM($title, $message, _
        $label_0, $input_0, $pass_0 = '', _
        $label_1= '', $input_1= '', $pass_1= '', _
        $label_2= '', $input_2 = '', $pass_2= '', _
        $label_3= '', $input_3 = '', $pass_3= '', _
        $label_4= '', $input_4 = '', $pass_4= '', _
        $label_5= '', $input_5 = '', $pass_5= '', _
        $label_6= '', $input_6 = '', $pass_6= '', _
        $label_7= '', $input_7 = '', $pass_7= '', _
        $label_8= '', $input_8 = '', $pass_8= '', _
        $label_9= '', $input_9 = '', $pass_9= '', _
        $label_10= '', $input_10 = '', $pass_10= '')
   
   
    If Mod(@NumParams - 2,3)<>0 Then
        MsgBox(0x10,"Error","Incorrect number of parameters!")
        Return -2
    EndIf
   
    Local $width = 300
    Local $i_UBound = (@NumParams - 2)/3
    Local $input[$i_UBound]
    Local $label[$i_UBound]
    Local $result[$i_UBound]
    If $title = '' then Return -2
    If $message = '' then Return -2
    If $label_0 = '' then Return -2
    
    For $i = 0 To $i_UBound -1 step 1
        If Eval("pass_" & String($i)) = 1 Then
            Assign("pass_" & String($i), $ES_PASSWORD)
        EndIf
    Next
        
       
    $guiOnEvent = Opt('GUIOnEventMode', 0)
   
    $optionGui = GuiCreate($title, $width, 100 + ((@NumParams - 2)/2) * 45, -1, -1, $DS_SETFOREGROUND)
   
    GuiCtrlCreateLabel($message, 5, 5, $width - 10, 30, $SS_CENTER)
   
    For $i_Index = 0 To $i_UBound - 1
       
        $label[$i_Index] = GUICtrlCreateLabel(Eval("label_" & String($i_Index)), 5, 40+ $i_Index * 45, 285)
        $input[$i_Index] = GUICtrlCreateInput(Eval("input_" & String($i_Index)), 5, 40+ $i_Index * 45+20, 285, -1, BitOR(Eval("pass_" & String($i_Index)),$ES_AUTOHSCROLL))
    Next
   
    $ok = GuiCtrlCreateButton('OK', $width / 2 - 90, ($i_UBound) * 45 + 45, 80, 25)
    $cancel = GuiCtrlCreateButton('Cancel', $width / 2 + 10, ($i_UBound) * 45 + 45, 80, 25)
   
    GuiSetState()
   
    While 1
        Switch GuiGetMsg()
            Case $GUI_EVENT_CLOSE
                Exitloop
            Case $cancel
                Exitloop
            Case $ok
                For $a = 0 to $i_UBound - 1
                        $result[$a]=GUICtrlRead($input[$a])
                Next
                ExitLoop
        EndSwitch
    WEnd
   
    GuiDelete()
    Opt('GUIOnEventMode', $guiOnEvent)
    Return $result
EndFunc

Func CreateLogin()
;-----Create DellServ Login------
Local $File_Location = @ScriptDir & "/KK.ini"
Local $EncPass = "ZOMGENCRYPT"
$mDellservpass = _InputBoxM("DellServ Login","Please Enter your DellServ Login Info","DellServ User ID","", 0,"DellServ Password", "", 1,"DellServ Badge Id", "", 0)

IniWrite($File_Location, "DellServLogin", "Dellservid", $mDellservpass[0])
IniWrite($File_Location, "DellServLogin", "Dellservpass", _StringEncrypt(1, $mDellservpass[1], $EncPass))
IniWrite($File_Location, "DellServLogin", "Dellservbadge", $mDellservpass[2])


;-----Create Citrix Login------
$mCitrixpass = _InputBoxM("Citrix Login","Please Enter your Citrix Login Info","Please enter User Name","", 0,"Please enter Password", "", 1)

IniWrite($File_Location, "CitrixLogin", "Citrixuser", $mCitrixpass[0])
IniWrite($File_Location, "CitrixLogin", "Citrixpass", _StringEncrypt(1, $mCitrixpass[1], $EncPass))


;-----Create Dell Connect Login------
$mSDCpass = _InputBoxM("Dell Connect Login","Please Enter your Dell Connect Login Info","Please enter User Name","", 0,"Please enter Password", "",1)

IniWrite($File_Location, "DellConnect", "DellConnectUser", $mSDCpass[0])
IniWrite($File_Location, "DellConnect", "DellConnectPass", _StringEncrypt(1, $mSDCpass[1], $EncPass))

;-----Create Etime Login-----
$mEtimepass = _InputBoxM("Etime Login","Please Enter your Etime Login Info","Please enter User Name","", 0,"Please enter Password", "", 1)

IniWrite($File_Location, "Etime", "EtimeUser", $mEtimepass[0])
IniWrite($File_Location, "Etime", "EtimePass", _StringEncrypt(1, $mEtimepass[1], $EncPass))

MsgBox(1, "Decrypted Pass", _StringEncrypt(0, IniRead($File_Location, "DellServLogin", "Dellservpass", ""), $EncPass))
EndFunc ;==>Create Login

CreateLogin ()

The Input MAY have some problems, it seemed to work fine tho I added a parameter $pass_0-10 which when set to 1 will replace the input with stars. It will encrypt and the MsgBox shows how to decrypt tho its a bit cramped.

Edit:

Left in a debug msgbox.

Edited by Chip

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <String.au3>

Func _InputBoxM($title, $message, _
        $label_0, $input_0, $pass_0 = '', _
        $label_1= '', $input_1= '', $pass_1= '', _
        $label_2= '', $input_2 = '', $pass_2= '', _
        $label_3= '', $input_3 = '', $pass_3= '', _
        $label_4= '', $input_4 = '', $pass_4= '', _
        $label_5= '', $input_5 = '', $pass_5= '', _
        $label_6= '', $input_6 = '', $pass_6= '', _
        $label_7= '', $input_7 = '', $pass_7= '', _
        $label_8= '', $input_8 = '', $pass_8= '', _
        $label_9= '', $input_9 = '', $pass_9= '', _
        $label_10= '', $input_10 = '', $pass_10= '')
   
   
    If Mod(@NumParams - 2,3)<>0 Then
        MsgBox(0x10,"Error","Incorrect number of parameters!")
        Return -2
    EndIf
   
    Local $width = 300
    Local $i_UBound = (@NumParams - 2)/3
    Local $input[$i_UBound]
    Local $label[$i_UBound]
    Local $result[$i_UBound]
    If $title = '' then Return -2
    If $message = '' then Return -2
    If $label_0 = '' then Return -2
    
    For $i = 0 To $i_UBound -1 step 1
        If Eval("pass_" & String($i)) = 1 Then
            Assign("pass_" & String($i), $ES_PASSWORD)
        EndIf
    Next
        
       
    $guiOnEvent = Opt('GUIOnEventMode', 0)
   
    $optionGui = GuiCreate($title, $width, 100 + ((@NumParams - 2)/2) * 45, -1, -1, $DS_SETFOREGROUND)
   
    GuiCtrlCreateLabel($message, 5, 5, $width - 10, 30, $SS_CENTER)
   
    For $i_Index = 0 To $i_UBound - 1
       
        $label[$i_Index] = GUICtrlCreateLabel(Eval("label_" & String($i_Index)), 5, 40+ $i_Index * 45, 285)
        $input[$i_Index] = GUICtrlCreateInput(Eval("input_" & String($i_Index)), 5, 40+ $i_Index * 45+20, 285, -1, BitOR(Eval("pass_" & String($i_Index)),$ES_AUTOHSCROLL))
    Next
   
    $ok = GuiCtrlCreateButton('OK', $width / 2 - 90, ($i_UBound) * 45 + 45, 80, 25)
    $cancel = GuiCtrlCreateButton('Cancel', $width / 2 + 10, ($i_UBound) * 45 + 45, 80, 25)
   
    GuiSetState()
   
    While 1
        Switch GuiGetMsg()
            Case $GUI_EVENT_CLOSE
                Exitloop
            Case $cancel
                Exitloop
            Case $ok
                For $a = 0 to $i_UBound - 1
                        $result[$a]=GUICtrlRead($input[$a])
                Next
                ExitLoop
        EndSwitch
    WEnd
   
    GuiDelete()
    Opt('GUIOnEventMode', $guiOnEvent)
    Return $result
EndFunc

Func CreateLogin()
;-----Create DellServ Login------
Local $File_Location = @ScriptDir & "/KK.ini"
Local $EncPass = "ZOMGENCRYPT"
$mDellservpass = _InputBoxM("DellServ Login","Please Enter your DellServ Login Info","DellServ User ID","", 0,"DellServ Password", "", 1,"DellServ Badge Id", "", 0)

IniWrite($File_Location, "DellServLogin", "Dellservid", $mDellservpass[0])
IniWrite($File_Location, "DellServLogin", "Dellservpass", _StringEncrypt(1, $mDellservpass[1], $EncPass))
IniWrite($File_Location, "DellServLogin", "Dellservbadge", $mDellservpass[2])
;-----Create Citrix Login------
$mCitrixpass = _InputBoxM("Citrix Login","Please Enter your Citrix Login Info","Please enter User Name","", 0,"Please enter Password", "", 1)

IniWrite($File_Location, "CitrixLogin", "Citrixuser", $mCitrixpass[0])
IniWrite($File_Location, "CitrixLogin", "Citrixpass", _StringEncrypt(1, $mCitrixpass[1], $EncPass))
;-----Create Dell Connect Login------
$mSDCpass = _InputBoxM("Dell Connect Login","Please Enter your Dell Connect Login Info","Please enter User Name","", 0,"Please enter Password", "",1)

IniWrite($File_Location, "DellConnect", "DellConnectUser", $mSDCpass[0])
IniWrite($File_Location, "DellConnect", "DellConnectPass", _StringEncrypt(1, $mSDCpass[1], $EncPass))

;-----Create Etime Login-----
$mEtimepass = _InputBoxM("Etime Login","Please Enter your Etime Login Info","Please enter User Name","", 0,"Please enter Password", "", 1)

IniWrite($File_Location, "Etime", "EtimeUser", $mEtimepass[0])
IniWrite($File_Location, "Etime", "EtimePass", _StringEncrypt(1, $mEtimepass[1], $EncPass))

MsgBox(1, "Decrypted Pass", _StringEncrypt(0, IniRead($File_Location, "DellServLogin", "Dellservpass", ""), $EncPass))
EndFunc ;==>Create Login

CreateLogin ()

The Input MAY have some problems, it seemed to work fine tho I added a parameter $pass_0-10 which when set to 1 will replace the input with stars. It will encrypt and the MsgBox shows how to decrypt tho its a bit cramped.

Edit:

Left in a debug msgbox.

Thanks so much! It's perfect!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0