예제 #1
0
    def Withdraw(self):
        clrscr()

        print_options(self.get_value("Username"), "Withdraw",
                      self.get_value("Address"), self.get_value("Balance"))
        print(
            "Enter the amount you want to withdraw. Press any letter to go back."
        )
        x = inpt("> ")

        if x.isdigit():
            x = int(x)
            if x <= 0:
                print(f"\033[91mYou can't withdraw ${x}\033[0m")
            elif x > int(self.get_value("Balance")):
                print("\033[91mInsufficient Funds.\033[0m")
            else:
                self.append_transaction(f"Withdrawed ${x}.")
                self.Account["Balance"] -= x
                return
        else:
            return

        self.update_account()
        inpt("Press \033[91menter\033[0m to continue")
예제 #2
0
    def show_transaction(self):
        clrscr()

        print("\033[93mTransaction Log\033[0m")
        x = 0
        for i in self.Account["TransactionLog"].values():
            print(i.replace(f"ID {x})", f"\033[94mID {x})\033[0m\n"))
            x += 1

        inpt("Press \033[91menter\033[0m to exit.")
예제 #3
0
    def show_all_info(self):
        clrscr()

        for key, value in self.Account.items():
            if key == "TransactionLog" or key == "TFA_Code" or key == "Password" or key == "CreditCardNumber" or key == "SecurityCode":
                continue

            print(f"\033[93m{key}\033[0m: {value}")

        inpt("Press \033[91menter\033[0m to continue")
예제 #4
0
    def New_Phone(self):
        print_options(self.get_value("Username"), "New Phone",
                      self.get_value("Address"), self.get_value("Balance"))

        while True:
            c = inpt("Your new phone number: ")

            if any(x.isdigit() for x in c) == True and len(c) == 10:
                self.Account["Phone"] = int(c)
                print("\033[92mPhone number changed!\033[0m")
                inpt("Press \033[91mEnter\033[0m to continue")
                break

            else:
                print(
                    "\033[91mInvaild phone number. Your number must have 10 digits.\033[0m"
                )

        self.update_account()
예제 #5
0
    def New_Password(self):
        print_options(self.get_value("Username"), "New Password",
                      self.get_value("Address"), self.get_value("Balance"))

        while True:
            x = inpt("Your new password: "******"Confirm new password: "******"Password"] = hashlib.blake2b(
                    x.encode()).hexdigest()
                print("\033[92mYou password changed!\033[0m")
                inpt("Press \033[91mEnter\033[0m to continue")
                break

            else:
                print(
                    "\033[91mYour confirmed password input doesn't match your new password! Please try again\033[0m"
                )

        self.update_account()
예제 #6
0
    def Deposit(self):
        clrscr()

        print_options(self.get_value("Username"), "Deposit",
                      self.get_value("Address"), self.get_value("Balance"))
        print(
            "Enter the amount you want to deposit. Enter any letter to go back."
        )

        x = inpt("> ")

        if x.isdigit():
            x = int(x)
            if x <= 0:
                print("\033[91mYou can't deposit $", x, "\033[0m")
            else:
                self.append_transaction(f"Deposited ${x}.")
                self.Account["Balance"] += x
                return
        else:
            return

        self.update_account()
        inpt("Press \033[91menter\033[0m to continue")
예제 #7
0
    def TFA(self):
        print_options(self.get_value("Username"), "Two Factor Authenthication",
                      self.get_value("Address"), self.get_value("Balance"))
        if self.Account["TFA"] == "True":
            self.Account["TFA"] = "False"
            print("\033[92m2FA Disabled.\033[0m")
            inpt("Press \033[91menter\033[0m to continue.")

        else:
            new_code = ""
            for _ in range(5):
                new_code += str(random.randint(0, 9))

            self.Account["TFA_Code"] = hashlib.blake2b(
                new_code.encode()).hexdigest()
            print(
                f"\033[92mTFA Enabled\033[0m, your code is \"\033[93m{new_code}\033[0m\""
            )

            inpt(
                "Press \033[91menter\033[0m when you've written down/remembered your TFA Code."
            )
            self.Account["TFA"] = "True"
        self.update_account()
예제 #8
0
def Login():
    clrscr()
    print("""
\033(0qqqqq\033(B
\033[93mLogin\033[0m
\033(0qqqqq\033(B
Input \"\033[91m-1\033[0m\" to go back. Enter of the following information...
""")

    username = inpt("\033[93mUsername: \033[0m")
    if username == "-1":
        return False

    print("\033(0qqqqqqqqqqq\033(B")

    password = inpt("\033[93mPassword: \033[0m")
    if password == "-1":
        return False

    setup_file()

    with open("Accounts.txt", "rb") as f:
        Accounts = f.read()
        Accounts = json.loads(base64.b64decode(Accounts).decode())

    if username in Accounts.keys():
        LocalAcc = LocalAccount(Accounts[username])
        if LocalAcc.Vaild and hashlib.blake2b(
                password.encode()).hexdigest() == LocalAcc.Account["Password"]:
            if LocalAcc.Account["TFA"] == "True":
                while True:
                    tfa_code = inpt("\033[93m2FA Code: \033[0m")

                    if hashlib.blake2b(tfa_code.encode()).hexdigest(
                    ) == LocalAcc.Account["TFA_Code"]:
                        LocalAcc.Home()
                        break
                    elif tfa_code == "-1":
                        return False
                    else:
                        print("\033[91mInvaild 2FA Code.\033[0m")
                        continue
            else:
                LocalAcc.Home()
        elif LocalAcc.Vaild and LocalAcc.Account[
                "Password"] != hashlib.blake2b(password.encode()).hexdigest():
            print("\033[91mIncorrect password.\033[0m")
            inpt("Press Enter to continue.")
            return False
        else:
            print(
                "\033[91mYour account has invaild account information. Please register again.\033[0m"
            )
            inpt("Press Enter to continue.")
            return False
    else:
        print(
            "\033[91mThis account does not exist, make sure you register this account before you log in again.\033[0m"
        )
        inpt("Press Enter to continue.")
        return False

    return True
예제 #9
0
def reg_ask(value, n):
    requirements = {
        "CreditCardNumber": 16,
        "SecurityCode": 4,
        "Postcode": 4,
        "Phone": 10
    }

    z = ""
    x = inpt("\033[93m" + value + "\033[0m")
    if x == "-1":
        return False

    for i in n:
        if i.isupper():
            z += ' '
        z += i

    if (x.isalnum() or x.isdigit()) == False and ("@" or ".") not in x:
        print(
            "\033[91mYou can only type letters or numbers. (No spaces, symbols, etc)\033[0m"
        )
        return True

    elif n == "CreditCardNumber" or n == "SecurityCode" or n == "Postcode" or n == "Phone":
        if not x.isdigit():
            print(
                "\033[91mValue", z,
                " needs to be a number. (No letters, spaces, symbols...)\033[0m"
            )
            return True
        elif n == "CreditCardNumber" and len(x) != 16 or (
                n == "Postcode"
                and len(x) != 4) or (n == "Phone"
                                     and len(x) != 10) or (n == "SecurityCode"
                                                           and len(x) != 4):
            print("\033[91mValue ", z, " needs a total of", requirements[n],
                  " digits.\033[0m")
            return True

    elif n == "FirstName" or n == "LastName":
        if x.isdigit():
            print("\033[91mValue ", z, " should not have digits.\033[0m")
            return True

    elif x.isdigit() and n != "Password":
        print("\033[91mValue ", z, "should not have digits.\033[0m")
        return True

    elif n == "Username":
        setup_file()

        with open("Accounts.txt", "rb") as f:
            z = json.loads(base64.b64decode(f.read()).decode())

            if x in z.keys():
                print("\033[91mUsername already taken.\033[0m")
                return True
    elif n == "Email":
        if bool(re.search(r"^[\w\.\+\-]+\@[\w]+\.[a-z]{2,3}$", x)) == False:
            print("\033[91mInvaild email. Example: [email protected]\033[0m")
            return True
    return x
예제 #10
0
""")
        print_menu(options)
        if getKeyMenu(options) == "return":
            break
    return


if __name__ == "__main__":
    clrscr()
    print(
        "It's highly reccomended to use terminals that support ANSI.\n\nTerminals like:\n\tVisual Studio Code Integrated Terminal\n\tThe NEW Windows Terminal (https://github.com/microsoft/terminal)\n\nIs highly reccomended to use for this program to work perfectly."
    )
    print("Press Enter 3 times.")

    for _ in range(3):
        inpt(f"Press Enter to continue. [{_}]")

    init()
    main()
"""
References:
    - https://en.wikipedia.org/wiki/ANSI_escape_code
    - https://ozzmaker.com/add-colour-to-text-in-python/
    - https://voidinit.com/python/console/files
    - https://docs.python.org/3/library/json.html
    - http://www.json.org/example.html
    - https://docs.python.org/3/library/functions.html#any
    - https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
    - Current python Knowledge

Mindmap: https://www.draw.io/#HJushBJJ%2FDigital-Technology-Highschool%2Fmaster%2Fgrade%209%2FBank