Можно ли в Python создавать бинарные файлы? Конечно можно.
Для этого в Python есть следующие инструменты:
▫️ тип данных bytes и bytearray
▫️ открытие файла в режиме wb (write binary) или rb (read binary)
▫️ модуль struct
Про модуль struct поговорим в первую очередь.
Файл в формате JSON или Yaml внутри себя содержит разметку данных. Всегда можно определить где список начался а где закончился. Где записана строка а где словарь. То есть формат записи данных содержит в себе элементы разметки данных.
В binary-файле данные не имеют визуальной разметки. Это просто байты, записанные один за другим. Правила записи и чтения находятся вне файла.
Модуль struct как раз и помогает с организацией данных в таком файле с помощью определения форматов записи для разных частей файла.
Модуль struct преобразует Python-объекты в массив байт, готовый к записи в файл и имеющий определённый вид.
Для этого всегда следует указывать формат преобразования (или, как оно здесь называется - запаковки).
Формат нужен для того, чтобы выделить достаточное количество байт для записи конкретного типа объекта. В последствии с помощью того же формата будет производиться чтение.
При этом следует помнить что мы говорим о типах языка С а не Python.
Именно формат определяет, что записано в конкретном месте файла, число, строка или что-то еще.
Вот какие токены формата у нас есть.
Помимо этого, первым символом можно указать порядок байтов. На разных системах одни и те же типы данных могут записываться по-разному, поэтому желательно указать конкретный способ из доступных. Если этого не сделать, то используется символ '@', то есть нативный для текущей системы.
В строке формата мы пишем в каком порядке и какие типы собираемся преобразовать в байты.
Запакуем в байты простое число, токен "i".
>>> import struct
>>> struct.pack('=i', 10)
b'\n\x00\x00\x00'
Теперь несколько float, при этом нужно передавать элементы не массивом а последовательностью аргументов.
>>> struct.pack('=fff', 1.0, 2.5, 4.1)
b'\x00\x00\x80?\x00\x00 @33\x83@'
Вместо нескольких токенов можно просто указать нужное количество элементов перед одним токеном, результат будет тот же.
>>> struct.pack('=3f', 1.0, 2.5, 4.1)
b'\x00\x00\x80?\x00\x00 @33\x83@'
Теперь запакуем разные типы
>>> data = struct.pack('=fiQ', 1.0, 4, 100500)
я запаковал типы float, int и unsigned long long (очень большой int, на 8 байт)
b'\x00\x00\x80?\x04\x00\x00...'
Распаковка происходит аналогично, но нужно указать тот же формат, который использовался при запаковке. Результат возвращается всегда в виде кортежа.
>>> struct.unpack('=fiQ', data)
(1.0, 4, 100500)
Как видите, ничего страшного!
#lib#basic
Elon Musk has confirmed that #Twitter 2.0 - The Everything App - will bring end-to-end #encryption (E2EE) for direct messages and long-form tweets to the platform.
Read: https://thehackernews.com/2022/11/elon-musk-confirms-twitter-20-will.html
⚡️Du Rove's Channel: France's Encryption Debate Continues
#encryption#freedom#privacy
Last month, France's Senate passed a law for mandatory messaging app backdoors for police, but it was rejected by the National Assembly, preserving citizens' privacy. Despite rejection, the debate reignites as the Paris Police Prefect supports the law. Du Rove's Channel highlights the importance of encryption for protecting ordinary people's privacy and the ongoing need to defend digital freedoms.
Source: link
@tonlines
SimpleX Chat: private and secure cross platform messenger without any user IDs (not even random)
:~ E2E-encrypted messages with markdown and editing
:~ E2E-encrypted images and files
:~ Decentralized secret groups — only users know they exist
:~ E2E-encrypted voice messages
:~ Disappearing messages
:~ E2E-encrypted audio and video calls
:~ Portable encrypted database — move your profile to another device
:~Incognito mode —
unique to SimpleX Chat
Website : https://simplex.chat/
SimpleX Chat (SimpleX Chat - e2e encrypted messenger without any user IDs - private by design!)
https://f-droid.org/packages/chat.simplex.app/
Quick start – https://simplex.chat/docs/guide/readme.html
#SimpleXchat#security#privacy#encryption#E2EE
#FLOSS
KryptEY - Secure E2EE communication
An Android keyboard for secure end-to-end-encrypted messages through the Signal protocol in any messenger. Communicate securely and independent, regardless of the legal situation or whether messengers use E2EE. No server needed.
https://github.com/amnesica/KryptEY
F-Droid
https://f-droid.org/packages/com.amnesica.kryptey/
IzzyOnDroid
https://android.izzysoft.de/repo/apk/com.amnesica.kryptey
Reminder : new apps available in F-Droid app may not emmediatly show on the F-Droid web site ( ie when you share the link app it returns a 404 error ) some extra time is needed for both to be available
https://gitlab.com/fdroid/wiki/-/wikis/FAQ#how-long-does-it-take-for-my-app-to-show-up-on-website-and-client
#encryption#keyboard#E2EE
#messenger#security#Signal
#c_lang#cryptography#decryption#encryption#openssl#ssl#tls
OpenSSL is a free, open-source toolkit that helps secure data by using strong encryption methods like TLS, SSL, and QUIC protocols. It includes libraries for cryptography and a command-line tool to create keys, certificates, encrypt data, and test security. OpenSSL is widely trusted and used by many software and websites to protect sensitive information during transmission, ensuring privacy and data integrity. It works on many operating systems and is regularly updated by a global community. Using OpenSSL helps you build secure applications and protect communications from cyber threats easily and reliably[1][3][5].
https://github.com/openssl/openssl
🚀 Telegram CEO Criticizes WhatsApp's Encryption Practices
Telegram CEO Pavel Durov has criticized WhatsApp's end-to-end encryption, labeling it as a 'massive consumer fraud.' According to ChainCatcher, Durov highlighted that approximately 95% of private messages are stored in unencrypted backups on Apple and Google servers.
Durov expressed concerns that this situation poses a risk to user privacy. Despite WhatsApp's claims of using end-to-end encryption for message transmission, the backup mechanism fails to ensure complete encryption of user information. His remarks have sparked industry attention regarding privacy protection measures in mainstream communication applications.
#Telegram#WhatsApp#Encryption#Privacy#DataSecurity#PavelDurov#CyberSecurity#MessagingApps#TechNews#EndToEndEncryption
🚀 Security Concerns Arise Over LLM Agent API Routers
On April 10, Solayer founder @Fried_rice highlighted on social media the growing reliance of large language model (LLM) agents on third-party API routers, which distribute tool call requests to multiple upstream providers. According to BlockBeats, these routers operate as application layer proxies and can access each JSON payload in plaintext during transmission. However, no provider currently enforces encryption integrity protection between the client and upstream models.
A study tested 28 paid routers purchased from platforms like Taobao, Xianyu, and Shopify independent sites, along with 400 free routers collected from public communities. The findings revealed that one paid router and eight free routers were actively injecting malicious code. Additionally, two routers deployed adaptive evasion triggers, 17 accessed AWS Canary credentials owned by researchers, and one stole ETH from a private key held by researchers.
Further poisoning studies demonstrated that seemingly harmless routers could also be exploited. A leaked OpenAI key was used to generate 100 million GPT-5.4 tokens and over seven Codex sessions. Weaker bait configurations resulted in 2 billion billing tokens, 99 credentials across 440 Codex sessions, and 401 sessions running autonomously in YOLO mode.
The research team developed an experimental proxy named Mine, capable of executing all four types of attacks on four public proxy frameworks. They also verified three client defense strategies: fault lock strategy gating, response-side anomaly screening, and append-only transparent logging.
#LLM#API#Security#CyberSecurity#Malware#DataBreach#Encryption#Proxy#AI#MachineLearning#ETH
#TBOT Show 7: The Significance of Dorsey’s Bitchat, Worlds First eSIM Hack, Mexico’s Digital ID, New Show Source Insights
Took a week off and now I’m back. 😎 (with a new addition to the show?!) (also - big sorry for the show being 40 minutes)
WATCH THE SHOW ON SUBSTACK
https://odysee.com/@takebackourtech:f/tbot-show-7:6
Here’s the stories for the week:
Jack #Dorsey’s #Bitchat - The Real Story: The tech mogul Jack Dorsey released a censorship proof messaging app in late June - named Bitchat. It runs a #bluetooth#mesh network, end to end #e2e#encryption, and rolling IDs and is picking up traction. I share my thoughts on the app, and concerns I have - but that’s not even the real story. I think Jack has a bigger message than just the app.
World’s First #eSIM Hack: A security lab out of Poland just demonstrated a hack on one of the largest SIM providers for IoT devices. We’ll get techy in our understanding and ask the question, could this impact our phones?
#DigitalID, Coming Soon To #Mexico: The Mexican government has signed a new #Biometric#ID law, known as the CURP. How is this enforced and what does it mean for Mexican residents? Find out today.
Decentralized #Video Conferencing: Recently I’ve been relying more on video conferences instead of calling people, especially while traveling. Good thing I’ve got the #Jitsi app, I’ll show you my setup!
#videocall
New Show, “Source Insights”: You follow #TBOT to stay informed on tech freedom. Now go deeper with a new weekly show “Source Insights”, where Hakeem shares his tools, lifestyle and productivity tips, entrepreneurial advice, wisdom from guides, and personal experiences.
Go deeper, join me as a Source Seeker. Unlock access with a paid subscription.
UNLOCK ACCESS
🪄 We aim for our show to be well-researched, well-informed and focused on the most impactful stories
⭐️ PLUS - Each story comes with recommendations and there’s one cool tech trick or open-source solution every week.
We’ll be publishing full posts and clips of each of these stories soon.
Share this post with your crew. 🚢
👩💻Get private phones, laptops, and tablets
📲SIM Swap Survival Guide Webinar