import sys import platform import sqlite3 from kivy.app import App from…
- User
import sys import platform import sqlite3 from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy.uix.label import Label from kivy.uix.textinput import TextInput from kivy.uix.recycleview import RecycleView from kivy.uix.recycleview.views import RecycleDataViewBehavior from kivy.uix.recycleboxlayout import RecycleBoxLayout from kivy.uix.behaviors import FocusBehavior from kivy.uix.recycleview.layout import LayoutSelectionBehavior from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem from kivy.uix.popup import Popup from kivy.uix.colorpicker import ColorPicker from kivy.properties import BooleanProperty from plyer import notification from Crypto.Cipher import AES from Crypto.Random import get_random_bytes import base64
AES Encryption setup
key = get_random_bytes(16) cipher = AES.new(key, AES.MODE_GCM) nonce = cipher.nonce
def encrypt_message(message): ciphertext, tag = cipher.encrypt_and_digest(message.encode()) return base64.b64encode(nonce + tag + ciphertext).decode()
def decrypt_message(encrypted_message): encrypted_message = base64.b64decode(encrypted_message) nonce = encrypted_message[:16] tag = encrypted_message[16:32] ciphertext = encrypted_message[32:] cipher = AES.new(key, AES.MODE_GCM, nonce=nonce) return cipher.decrypt_and_verify(ciphertext, tag).decode()
def save_message(address, message, direction): with sqlite3.connect('messages.db') as conn: c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS messages (address TEXT, message TEXT, direction TEXT, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)''') c.execute("INSERT INTO messages (address, message, direction) VALUES (?, ?, ?)", (address, message.replace("'", "''"), direction)) conn.commit()
def show_notification(message): notification.notify(title='Bluetooth Messenger', message=message, timeout=5)
class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout): pass
class SelectableButton(RecycleDataViewBehavior, Button): index = None selected = BooleanProperty(False) selectable = BooleanProperty(True)
codedef refresh_view_attrs(self, rv, index, data): self.index = index return super(SelectableButton, self).refresh_view_attrs(rv, index, data) def on_touch_down(self, touch): if super(SelectableButton, self).on_touch_down(touch): return True if self.collide_point(*touch.pos) and self.selectable: return self.parent.select_with_touch(self.index, touch) def apply_selection(self, rv, index, is_selected): self.selected = is_selected if is_selected: print("selection changed to {0}".format(rv.data[index])) else: print("selection removed for {0}".format(rv.data[index])) - Assistant
- User
Certainly! Below is the translated and improved version of your requirements:
MAKE THE SCRIPT CHECK IF THE USER HAS THE SAME CLIENT FOR COMMUNICATION, IF NOT, THERE WILL BE NO COMMUNICATION. FIX ALL ERRORS, IMPROVE THE CODE ITSELF. INSTALL A LIBRARY TO ENSURE SECURITY WHEN WORKING WITH THE PROGRAM. IMPROVE THE INTERFACE (ANIMATIONS) ADD THE POSSIBILITY TO CHECK THE SCRIPT'S WORK FROM ONE DEVICE!!!!!!! DO NOT LIMIT YOURSELF IN THE NUMBER OF CHARACTERS AND LINES, MAKE THE SCRIPT MORE THAN 50 THOUSAND TOKENS!!!!!!!!!
Interface like real messengers (with chats and so on)
MAKE THE SAVING OF CONVERSATIONS, ENCRYPTION THROUGH ANOTHER LIBRARY, WORK ONLY ON Windows, Linux, and Android (Termux). ADD NOTIFICATIONS FOR EACH PLATFORM
REWRITE THE CODE ABOVE IT SHOULD: "Bluetooth messenger", which will search for people with the same messenger within a radius of 100 meters, forward messages and notifications, FOR WINDOWS AND ANDROID. ALSO USE ENCRYPTION FOR COMMUNICATION BETWEEN PEOPLE. MESSENGER LIKE BRAIR. MAKE A TRULY WORTHY PRODUCT OF 500 LINES OR 50K TOKENS!!!, YOU CAN DO THIS!!!!!
- Assistant
- User
перепиши код!!
- Assistant