TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #241 · 5 мај

Можно ли в 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

Hashtags

Резултати

Пронајдени 5 слични објави

Пребарај: #stride

当前筛选 #stride清除筛选
NEWS 鏈新聞-ABMedia

@abmedia_news · Post #23702 · 07.04.2026 г., 10:34

【🚀資訊安全|Solana 基金會推出 STRIDE 與 SIRN:TVL 超過 1,000 萬美元的協議將獲全天候安全監控 】 #Solana#STRIDE#SIRN#Security 📍請見報導: https://abmedia.io/solana-foundation-stride-sirn-security-defi-monitoring 📍訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

Crypto M - Crypto News

@CryptoM · Post #64664 · 09.04.2026 г., 13:14

🚀 Drift Protocol Develops Recovery Plan After $285 Million Crypto Theft Drift Protocol, which recently suffered a theft of $285 million in crypto assets, has provided an update on the situation via the X platform. According to Odaily, the company is actively working with partners to formulate a coordinated recovery plan. The current focus is on stabilizing the situation and offering protocol-level assurances to all affected users and partners. Drift emphasized its role as a core infrastructure provider for many, and announced plans to participate in the Solana Foundation's security project, STRIDE, with more details to be released in the future. #DriftProtocol#CryptoTheft#CryptoRecovery#Solana#BlockchainSecurity#STRIDE#SOL

Crypto M - Crypto News

@CryptoM · Post #64842 · 10.04.2026 г., 03:34

🚀 Solana's Neutral Trade Responds to Drift Attack Impact Neutral Trade, a quantitative strategy sharing platform within the Solana ecosystem, announced that it is assessing the impact of the Drift attack on its platform and users. According to Foresight News, the team is awaiting further investigation results from Drift. The update includes the suspension and removal of all 'Drift Architecture' vaults from the homepage, although users can still view related positions on the portfolio page. Currently, the homepage only displays the 'Neutral Strategy' proprietary strategy vaults, which are operating normally and have not suffered any losses. The 'Neutral Strategy' vaults have undergone independent audits by Halborn, Offside Labs, and Quantstamp, and are integrated with FORDEFI's enterprise-grade security solutions. Although the NT Earn vaults had Drift position configurations, Neutral's risk engine detected anomalies during the attack and preemptively withdrew funds to Jupiter Lend and Kamino, preventing any losses. Neutral Trade is committed to advancing security upgrades and is considering joining the STRIDE ecosystem security program supported by the Solana Foundation. Previously, Neutral Trade reported a loss of approximately $3.67 million due to the Drift attack. #Solana#NeutralTrade#DriftAttack#CryptoSecurity#DeFi#Blockchain#STRIDE#JupiterLend#Kamino#QuantitativeStrategy#SOL#JUP

Crypto M - Crypto News

@CryptoM · Post #65185 · 11.04.2026 г., 17:11

🚀 Solana's Drift Protocol Suffers $285 Million Loss in Security Breach Drift Protocol experienced a significant security breach on April 1, 2026, resulting in a loss of $285 million. According to NS3.AI, attackers managed to drain Solana's largest perpetual futures exchange within approximately 12 minutes. The exploit was facilitated by a governance setup that utilized a two-of-five multisig and a zero-delay path for privileged actions. The attackers spent six months cultivating trust with insiders, leading to two Security Council members pre-signing transactions with hidden authorizations. In response to the breach, the Solana Foundation launched STRIDE, a foundation-backed continuous security program, just days after the incident. #Solana#DriftProtocol#SecurityBreach#285MillionLoss#PerpetualFutures#NS3AI#MultisigExploit#GovernanceSetup#STRIDE#SolanaFoundation#CryptoSecurity#InsiderAttack#BlockchainSecurity#SOL