Advertisement
Guest User

Untitled

a guest
Sep 1st, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.40 KB | None | 0 0
  1. import random, sqlite3, datetime
  2.  
  3. ### VARIABLES ###
  4. conn = sqlite3.connect('bank.db')
  5. c = conn.cursor()
  6. date = str(datetime.date.today())
  7. caeser_strings = []
  8. encrypt = []
  9. #################
  10.  
  11. # Custom (bad) cipher
  12. def cipher(string):
  13.     for letter in string:
  14.         number = ord(letter) - 96
  15.         caeser_strings.append(number + 12)
  16.  
  17.     for item in caeser_strings:
  18.         item += 3
  19.         item *= 15
  20.         item -= 43
  21.         encrypt.append(item)
  22.     return str(encrypt)
  23.  
  24.  
  25. def login():
  26.     pass
  27.  
  28. def register():
  29.     print("Welcome to PyBank, please input your desired credentials below.")
  30.     print("===============================================================")
  31.  
  32.     ### While loop incase confirm password is wrong. ###
  33.     while True:
  34.         forename = input("Forename: ")
  35.         surname = input("Surname: ")
  36.         user = input("Username: ")
  37.         pword = input("Password: ")
  38.         cPassword = input("Confirm Password: ")
  39.         e_mail = input("E-mail: ")
  40.         ### If the inputs aren't up to standard ###
  41.         if(len(forename) < 2 or len(surname) < 2): print("You cannot have a space in your name or it is less than two character. TIP: your first name is your forename.")
  42.         elif('@' not in e_mail and pword != cPassword): print("Passwords do not match and you need a valid email address.")
  43.         elif(pword != cPassword): print("Passwords do not match.") #Checking if the passwords are equal
  44.         elif('@' not in e_mail): print("You need a valid email address.")
  45.         else:
  46.             pword = cipher(pword);
  47.             c.execute('INSERT INTO accounts (date, forename, surname, username, password, email, balance) VALUES (?, ?, ?, ?, ?, ?, ?)',
  48.                 (date, forename, surname, user, pword, e_mail, 5000))
  49.             conn.commit()
  50.         break
  51.        
  52. def home():
  53.     pass
  54.  
  55. ### SQLite creating a table ###
  56. c.execute('CREATE TABLE IF NOT EXISTS accounts(id INTEGER PRIMARY KEY AUTOINCREMENT, forename TEXT, surname TEXT, date TEXT, username TEXT, password TEXT, email TEXT, balance REAL)')
  57.  
  58. ### Choosing whether the client would like to log in or register. ###
  59. while True:
  60.     user_choice = input("Login or Register: ").lower()
  61.     if(user_choice == "login"):
  62.         login();
  63.         break
  64.     elif(user_choice == "register"):
  65.         register();
  66.         break
  67.     else:
  68.         print("Invalid input, login or register only.")
  69.  
  70. # TO DO
  71. # 1) Register system [x]
  72. # 2) Cipher system [x]
  73. # 3) Login system
  74. # 4) Home screen
  75. # 5) Withdraw money
  76. # 6) Transfer money to another account
  77. # 7) Deposit money
  78. # 8) Possibly a system to send emails.
  79. # 8) Make into a GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement