Jump to content

Recommended Posts

This script keeps track of all your passwords(Encrypted), so you only need to remember 1 password.

Posted Image

#include <String.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
Global $ini = @HomeDrive & "\PK.ini"
Global $Encrypt_Level = 1
Global $Enter = False
Global $i = 0
Global $InvalidAttempts = 0
Load()

Func Load()
    If FileExists($ini) Then
        Global $TotalArrays = IniRead($ini, "Arrays", "Arrays", "")
        Global $Description[$TotalArrays + 1]
        Global $Username[$TotalArrays + 1]
        Global $Password[$TotalArrays + 1]
        Global $GUI_List[$TotalArrays + 1]
        For $i = 0 To $TotalArrays
            $Read1 = IniRead($ini, "Descriptions", "Description" & $i, "")
            $Description[$i] = _StringEncrypt(0,$Read1,"PasswordKeeper")
            $Read2 = IniRead($ini, "Usernames", "Username" & $i, "")
            $Username[$i] = _StringEncrypt(0,$Read2,"PasswordKeeper")
            $Read3 = IniRead($ini, "Passwords", "Password" & $i, "")
            $Password[$i] = _StringEncrypt(0,$Read3,"PasswordKeeper")
        Next
    EndIf
EndFunc  ;==>Load
If Not FileExists($ini) Then
    Setup()
Else
    Login()
EndIf
Func Add()
    GUIDelete("PasswordKeeper - Logged In")
    If Not FileExists($ini) Then
        Global $TotalArrays = 0
    Else
        Global $TotalArrays = IniRead($ini, "Arrays", "Arrays", "")
        If $TotalArrays = "" Then
            $TotalArrays = 0
        Else
            $TotalArrays += 1
        EndIf
    EndIf
    $User_Description = InputBox("Description", "")
    $User_Username = InputBox("Username", "")
    $User_Password = InputBox("Password", "")
    $User_Description = _StringEncrypt(1,$User_Description,"PasswordKeeper")
    $User_Username = _StringEncrypt(1,$User_Username,"PasswordKeeper")
    $User_Password = _StringEncrypt(1,$User_Password,"PasswordKeeper")
    IniWrite($ini, "Descriptions", "Description" & $TotalArrays, $User_Description)
    IniWrite($ini, "Usernames", "Username" & $TotalArrays, $User_Username)
    IniWrite($ini, "Passwords", "Password" & $TotalArrays, $User_Password)
    IniWrite($ini, "Arrays", "Arrays", $TotalArrays)
    Sleep(200)
    Load()
    LoggedIn()
EndFunc  ;==>Add
Func LoggedIn()
    GUICreate("PasswordKeeper - Logged In", 421, 267)
    $GUI_ListView = GUICtrlCreateListView("Description                      |Username                       |Password", 0, 0, 424, 250)
    $GUI_Add = GUICtrlCreateButton("Add Pass", 140, 248, 55, 20)
    $GUI_Del = GUICtrlCreateButton("Del Pass", 195, 248, 55, 20)
    ControlDisable("PasswordKeeper - Logged In", "", $GUI_Del)
    Global $TotalArrays = IniRead($ini, "Arrays", "Arrays", "")
    If Not $TotalArrays = "" Then
        For $i = 0 To $TotalArrays
            $GUI_List[$i] = GUICtrlCreateListViewItem($Description[$i] & "|" & $Username[$i] & "|" & $Password[$i], $GUI_ListView)
        Next
    EndIf
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        If $msg = -3 Then Exit
        If $msg = $GUI_Add Then Add()
        If $msg = $GUI_Del Then
        EndIf
    WEnd
EndFunc  ;==>LoggedIn
Func Del()
EndFunc  ;==>Del
Func EnterPressed()
    Global $Enter = True
EndFunc  ;==>EnterPressed

Func Login()
    $GUI = GUICreate("PasswordKeeper - Login", 300, 100)
    $GUI_Label = GUICtrlCreateLabel("Password:", 50, 28)
    $GUI_Password = GUICtrlCreateInput("", 100, 25, 100, 20, $ES_PASSWORD)
    $GUI_Login = GUICtrlCreateButton("Login", 120, 75, 40, 20)
    GUISetState()
    While 1
        If WinActive("PasswordKeeper - Login") Then
            HotKeySet("{Enter}", "EnterPressed")
        Else
            HotKeySet("{Enter}")
        EndIf
        $msg = GUIGetMsg()
        If $msg = -3 Then Exit
        If $msg = $GUI_Login Or $Enter = True Then
            Global $Enter = False
            If GUICtrlRead($GUI_Password) = "" Then
                MsgBox(0, "Login", "You must Enter a password.")
            Else
                $Convert = _StringToHex(GUICtrlRead($GUI_Password))
                $Encrypted = _StringEncrypt(1, $Convert, GUICtrlRead($GUI_Password) & "PasswordKeeper(" & @ComputerName & ")", $Encrypt_Level)
                $Pass_Encrypted = IniRead($ini, "A", "User", "")
                If $Encrypted = $Pass_Encrypted Then
                    HotKeySet("{Enter}")
                    GUICtrlDelete($GUI_Login)
                    GUICtrlDelete($GUI_Password)
                    GUICtrlDelete($GUI_Label)
                    GUIDelete($GUI)
                    ExitLoop
                Else
                    HotKeySet("{Enter}")
                    MsgBox(0, "Password", "Invalid password, please try again.")
                    GUICtrlSetData($GUI_Password, "")
                    $InvalidAttempts += 1
                    If IniRead($ini, "ZXY", "UserD", "") = 1 And $InvalidAttempts >= IniRead($ini, "ZXY", "UserA", "") Then
                        FileDelete($ini)
                        Exit
                    EndIf
                    
                EndIf
            EndIf
        EndIf

        Sleep(50)
    WEnd
    LoggedIn()
EndFunc  ;==>Login
Func Setup()
    $GUI = GUICreate("PasswordKeeper - Create Account", 300, 200)
    Global $GUI_Del_CheckBox = GUICtrlCreateCheckbox("Delete After:", 15, 125)
    Global $GUI_Del_Input = GUICtrlCreateInput("0", 95, 126, 28, 20)
    $GUI_Label2 = GUICtrlCreateLabel("Invalid Logins", 129, 126)
;
    $GUI_Label1 = GUICtrlCreateLabel("Password:", 50, 28)
    $GUI_Password = GUICtrlCreateInput("", 100, 25, 100, 20, $ES_PASSWORD)
    $GUI_Label2 = GUICtrlCreateLabel("Confirm:", 55, 53)
    $GUI_Confirm = GUICtrlCreateInput("", 100, 50, 100, 20, $ES_PASSWORD)
    $GUI_Create = GUICtrlCreateButton("Create", 120, 75, 40, 20)
    GUISetState()
    HotKeySet("{Enter}", "EnterPressed")
    While 1
        $msg = GUIGetMsg()
        If WinActive("PasswordKeeper - Create An Account") Then
            HotKeySet("{Enter}", "EnterPressed")
        Else
            HotKeySet("{Enter}")
        EndIf

        If $msg = -3 Then Exit
        If $msg = $GUI_Create Or $Enter = True Then
            Global $Enter = False
            If GUICtrlRead($GUI_Password) = "" Then
                MsgBox(0, "Login", "You must Enter a password.")
            ElseIf Not (GUICtrlRead($GUI_Password) == GUICtrlRead($GUI_Confirm)) Then
                MsgBox(0, "Login", "Passwords do not match!")
            Else
                $Convert = _StringToHex(GUICtrlRead($GUI_Password))
                $Encrypted = _StringEncrypt(1, $Convert, GUICtrlRead($GUI_Password) & "PasswordKeeper(" & @ComputerName & ")", $Encrypt_Level)
                IniWrite($ini, "A", "User", $Encrypted)
                HotKeySet("{Enter}")
                If GUICtrlRead($GUI_Del_CheckBox) = 1 Then
                    $Attempts = GUICtrlRead($GUI_Del_Input)
                    IniWrite($ini, "ZXY", "UserD", "1")
                    IniWrite($ini, "ZXY", "UserA", $Attempts)
                Else
                    IniWrite($ini, "ZXY", "UserD", "0")
                EndIf
                MsgBox(0, "Account", "Your account has been successfully created!")
                GUIDelete($GUI)
                GUICtrlDelete($GUI_Label1)
                GUICtrlDelete($GUI_Label2)
                GUICtrlDelete($GUI_Password)
                GUICtrlDelete($GUI_Confirm)
                GUICtrlDelete($GUI_Create)
                ExitLoop
            EndIf
        EndIf
        Sleep(50)
    WEnd
    Login()
EndFunc  ;==>Setup
Edited by will88
Link to post
Share on other sites

It still shows as :

[A]

User=fdgtdgtgrthytntuyjuntyb

[ZXY]

UserD=0

[Descriptions]

Description0=Test Item

[usernames]

Username0=Username

[Passwords]

Password0=Password

[Arrays]

Arrays=0

You need to delete the old ini file then it should work properly. Edited by will88
Link to post
Share on other sites
  • 4 months later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...