jimMoonrock

Untitled

May 9th, 2021
649
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  def __create_card(self):
  2.         random.seed(random.randint(0, 5000))
  3.         card = 4000000000000000 + random.randint(0000000000, 9999999999)
  4.         pin = (random.randint(0, 9999))
  5.         pin = str(pin).zfill(4)
  6.  
  7.         self.__converted_list_of_numbers = list(map(int, list(str(card))))[::-1]
  8.         self.__last_digit_card, self.__card_number_sum = 0, 0
  9.  
  10.         for num in range(0, len(self.__converted_list_of_numbers)):
  11.             if not num == 0:
  12.                 if num % 2 != 0:
  13.                     self.__card_number_sum += self.__converted_list_of_numbers[num] * 2 - 9 \
  14.                         if self.__converted_list_of_numbers[num] * 2 > 9 else \
  15.                         self.__converted_list_of_numbers[num] * 2
  16.                 else:
  17.                     self.__card_number_sum += self.__converted_list_of_numbers[num]
  18.             else:
  19.                 self.__last_digit_card = self.__converted_list_of_numbers[num]
  20.  
  21.  
  22.         if (self.__card_number_sum + self.__last_digit_card) % 10 == 0:
  23.             self.__function_selection = self.add(pin, card)
  24.         else:
  25.              self.__function_selection = self.__create_card()
  26.         return self.__function_selection
  27.  
  28.     def add(self, pin, card):
  29.         cur = self.conn.cursor()
  30.         cur.execute("select id from card where number=?", (str(card),))
  31.         data = cur.fetchall()
  32.         print(data)
  33.         if not data:
  34.  
  35.  
  36.  
  37.             self.__accounts[str(card)] = int(pin)
  38.             self.conn.execute('INSERT INTO card (number, pin) values( ?, ?)', (str(card), int(pin)))
  39.             print(f"""
  40.    Your card has been created
  41.    Your card number:
  42.    {card}
  43.    Your card PIN:
  44.    {pin}""")
  45.             self.conn.commit()
  46.         return self.main_menu()
  47.  
  48.  
  49.     def authorization(self):
  50.         for _ in iter(int, 1):
  51.             check_login = input("""
  52. Enter your card number:
  53. """)
  54.             check_pin = input("""Enter your PIN:
  55. """)
  56.             if check_login.isdigit() and check_pin.isdigit():
  57.                 check_pin = int(check_pin)
  58.                 if self.__accounts.get(check_login) == check_pin:
  59.                     print("""
  60. You have successfully logged in!""")
  61.                     self.__function_selection = self.user_account()
  62.                 else:
  63.                     print("""
  64. Wrong card number or PIN!""")
  65.                     self.__function_selection = self.main_menu()
  66.                 return self.__function_selection
  67.             else:
  68.                 continue
RAW Paste Data