<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Data Minimalism on Medium]]></title>
        <description><![CDATA[Stories by Data Minimalism on Medium]]></description>
        <link>https://medium.com/@dataminimalism?source=rss-15c396bcea9a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0WN6AN-8435_-cI2b_sysQ.jpeg</url>
            <title>Stories by Data Minimalism on Medium</title>
            <link>https://medium.com/@dataminimalism?source=rss-15c396bcea9a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:23:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dataminimalism/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Data Minimalist: How Small Teams Can Build Smarter Systems]]></title>
            <link>https://dataminimalism.medium.com/the-data-minimalist-how-small-teams-can-build-smarter-systems-998f03dba1a8?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/998f03dba1a8</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[data-architecture]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 15:41:56 GMT</pubDate>
            <atom:updated>2025-10-30T15:41:56.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*kG9uo7Vot0xnVujCsKepkg.png" /></figure><p><em>You can find all the minimalist data stacks articles on my substack (</em><a href="https://dataminimalism.substack.com/"><em>Data Minimalism</em></a><em>)</em></p><p>I co-founded a small investment company.</p><p>Like many small firms, we don’t have the luxury of a big data team or a bottomless budget. Yet, the need for reliable, actionable data is bigger than ever.</p><p>The problem? Most “modern data stacks” are designed for tech giants with dozens of engineers and huge budgets. Five orchestration layers, a costly cloud warehouse, and endless integrations. Trying to copy that in a small team is a trap. It’s expensive, fragile, and distracts from what actually matters: turning data into insight.</p><p><strong>The Solution: Data Minimalism</strong></p><p>Data minimalism isn’t about cutting corners . <strong>It’s about focus</strong>.</p><p>It means:</p><ul><li>Building systems you can understand from start to finish</li><li>Making choices based on real experiments</li><li>Prioritizing maintainability over trendiness</li><li>Automating where it actually adds leverage</li><li>Spending less on tools and more on clarity</li></ul><p>In short, it’s about designing data systems that a small team can own, trust, and scale. Without needing a dozen specialists.</p><p><strong>Why I Share This</strong></p><p>I document how we’re building our data infrastructure step by step.</p><p>You’ll see:</p><ul><li>The architectural choices we make and why</li><li>Tools we test, keep, or reject</li><li>How we balance cost, speed, and accuracy</li><li>Mistakes and lessons along the way</li></ul><p><strong>This isn’t theory</strong>. It’s the real, messy work of running a small business with big data needs.</p><p>If you run a small company (whether it’s a fund, a startup, or a bootstrapped business) this is for you. You don’t need a giant stack to get data right. You just need a clear philosophy and the discipline to build with intent.</p><p><strong>Join the Experiment</strong></p><p>Follow along on Substack. I share everything openly (designs, trade-offs, even failures). No paywalls, no fluff.</p><p>Let’s redefine what good data infrastructure means. Not for tech giants, but for the rest of us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=998f03dba1a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Reasong I Know There is Nothing Intelligent In AI (yet)]]></title>
            <link>https://dataminimalism.medium.com/the-reasong-i-know-there-is-nothing-intelligent-in-ai-yet-77eefd080ff1?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/77eefd080ff1</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 14:36:52 GMT</pubDate>
            <atom:updated>2025-01-11T14:36:52.557Z</atom:updated>
            <content:encoded><![CDATA[<h3>But we are getting closer and closer…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*sH-pHuvBP4uOcQOt" /><figcaption>Photo by <a href="https://gpealat.substack.com/p/true">Sajad Nori</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p>Access the unlimited story <a href="https://gpealat.substack.com/p/the-reason-there-is-nothing-intelligent?r=1t5iv">on my substack</a>.</p><p>AGI was the 2024 buzzword, but we are not close to freeing a force which will wipe out humanity (yet).</p><p>How impressive Large Language Model are, they are not thinking conscious machines. They are beautiful parrots which can trick you in believing they are a human being. They can bullshit their way through (hallucinate) if they don’t know the answer.</p><p>But to understand why we are still far away, we need to ask ourself what is intelligence?</p><h3>How Do I Define Intelligence?</h3><p>Defining intelligence is a very personal matter since not everybody sees problems the same way.</p><p>For some, Sir Isaac Newton’s invention of calculus to solve his problems makes him the most clever human being to have ever existed. Others believe the Albert Einstein’s understanding of gravity is the most important discovery ever. Heck, you might even find the new president elect the most intelligent guy on earth for his ability to bend the rules of law to his personal benefit.</p><p>See, we will never agree on what is a good definition of intelligence.</p><p>But, I will give you <strong>MY</strong> definition of intelligence — the one I use to judge the actual status of machine learning field.</p><p>Intelligence is being able to reflect on your own knowledge and adjust it as new information come to light. It is the power of deciding what is useful and what is not. And to rethink your vision of the world by reorganising your internal neural network.</p><p>And this is not at all what a LLM is all about.</p><h3>Why are the current models not that intelligent?</h3><p>Whatever the hype, todays models are not as intelligent — if you use the previous definition — as people believe.</p><p>They are very useful tools which extract what they have learned to answer questions. But what if a new major discovery hits the news? They won’t be able to help, or worse, they will lie about it as they lack the ability to ingest new information, hence giving you a false sense of knowledge.</p><p>And to swallow new information, there is a hefty price to pay.</p><p>According to Sam Altman, it costs $63 millions to train chatGPT4.</p><p>And your have to pay this cost numerous times a year. Because, you have to start from scratch each time you want to add new knowledge. Imagine if you had to go back to school (from kindergarten) when you wanted to learn a new skill for your job.</p><p>I am not sure this would be viable for your company.</p><h3>The Rise Of A New Era Of Cyborgs</h3><p>Human evolved by taking advantage of new tools, and today is not different.</p><p>Since the beginning of humanity, we made big step forwards by leveraging new tools. First, it was fire, then the wheel, and so on. We never stopped solving our problems by inventing new clever solutions.</p><p>There is a real causation between big jump in human condition with the creation of new tools.</p><p>Today, the era is not different from the age of the Roman empire..</p><p>A new tool has risen from the ashes -ML is not a new technology- thanks to an increase in computing power and few new discoveries. But ML is a companion for humans to go further in their understanding of the world. AI can help inventing new drugs, solve previously unsolvable problems…</p><p>But AI is a help to increase human capabilities, not a replacement.</p><p>The future belongs to the new Cyborgs, the people able to leverage this tool.</p><p>After any major changes in human history, the people who survived were the one who embraced the chaos which followed. We are at a crossroad in human history and the future belongs to people willing to accept those changes. AI presence in your live will be ever increasing, not receding any time soon.</p><p>Fight it and you will soon be redundant, accept it and you have a future.</p><h3>What lies ahead…</h3><p>This article could come across as negative toward LLM, but it is not.</p><p>I find the technology amazing, and its creative powers mesmerizing. But research is not over yet. Many discoveries lie ahead. One day we will reach AGI, once we have solved the intelligence problem.</p><p>One of those light in the dark are Liquid Neural Networks.</p><p>This new neural network architecture keeps learning even after training. And this is a potential game changer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77eefd080ff1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding data subspaces]]></title>
            <link>https://dataminimalism.medium.com/understanding-data-subspaces-bd8918dbc01e?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd8918dbc01e</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Sun, 05 Jan 2025 07:48:11 GMT</pubDate>
            <atom:updated>2025-01-05T07:48:11.318Z</atom:updated>
            <content:encoded><![CDATA[<h3>The most important concept to master data science and front run your competition</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NS67Qj72xZeH1ua0EJZnA.jpeg" /><figcaption>The Pleiades is a natural representation of clustering</figcaption></figure><blockquote>“Somewhere, something incredible is waiting to be known” — Carl Sagan</blockquote><p>Carl Sagan was talking about physics, but his wisdom is still valid for data science either. The role of a data scientist is to look at his raw material (data) and try to get insights. But you won’t discover new ideas by staring at your screen hoping something will pop up in your head. You must leave the world as you know it and invent a new universe where your data live: the <strong>data subspaces</strong>.</p><h3>An analogy with colour theory</h3><p>How many colours can a human see? The general guess is to say: an infinite number. But researchers proved it wrong: the human eye can see roughly about <em>10 million colours</em>. Not infinite but not a small number either.</p><p>How does it have to do with data? Think about colours as data you try to gain insight from. The basic way of representing them is to use a single number for each colour. You would need 10 millions of those, hardly related to each other. You will have a hard time extracting any insight from it.</p><p>Now, you can create a new universe: for example the RGB one. In this universe, you give to each colour a value corresponding to its Red, Blue and Green tint. Every colour exists in this space (as you can describe up to 256*256*256 colours). But you can explain and group all similar colours together. : for example the colour described by R:255 G:50 B:0 is closer to R:240 G:40 B:10 than R:0 G 100 B: 100.</p><h3>So, what are data subspaces?</h3><p>Data subspaces are lower-dimensional representations of a high-dimensional data space. It sounds very complex, but let’s look at the previous example. We moved from a 10 million dimension data space to a 3 dimensions one. We did it to simplify analysis, highlight specific patterns, or isolate meaningful features of the data.</p><p>When you are getting a new dataset, your aim is to discover which universe your data live in. Can you invent a dataspace where they fit in?</p><h3>How to find those data subspaces?</h3><p>There are many methods to create those new universes. We won’t go into detail, but we will give a quick glimpse of the possibilities.</p><p>- <strong>Dimension reduction</strong>: Earlier, we were able to redefine all our colours using the RGB scale. There was no loss of information. But we are rarely so lucky. Sometimes, we must decide a balance between loss of information and dimension reduction. Principal Component Analysis (or PCA) is the mathematical method for this task. PCA identifies subspaces that capture the most variance (information) in the data. It simplifies the representation while retaining significant information. We’ll see in a later article that PCA has some drawbacks.</p><p>- C<strong>lustering</strong>: Sometimes, there is not only one dataspace. A clever trick might be to classify your data by type of dataspace. Hierarchical clustering is a type of algorithm that groups your data for you. Another method is Support Vector Machine (SVM). The idea of SVM is to find a non-linear (read complex) projection. Then we project the data in a higher dimension space where we linearly solve the problem.</p><p>- <strong>Features extraction (FE)</strong>: FE selects or transforms features to form subspaces that are more relevant for a task. In the age of Generative AI, a common tool is embeddings. They are low-dimensional, dense, and continuous vector representations of data. They capture semantic or structural relationships in the data.</p><h3>Why is understanding data subspaces important?</h3><p>The reader could argue we have amazing machine learning models, so what is the point of all that? According to the <em>law of the instrument</em>, when we get a new skill, we tend to see opportunities to use it everywhere. This bias is also known as “the law of the hammer”. In machine learning, it is tempting to use complex models (like neural networks) for everything. But they are expensive to run (and I am not talking about the production part). So finding a simpler alternative is often welcomed.</p><p>Humans understand the linear regression well. Almost everybody is comfortable with a straight line. But you start to lose a lot of people once you move to a parabola. This fact has always puzzled me, but this is the sad state of science knowledge in the general population.</p><p>As a data scientist, your aim is to find a subspace where your data problem becomes linear (or close to linear). When successful, you will rip many benefits: quicker run time, cheaper costs, and simpler explanations to the stakeholders.</p><p>Understand the universe in which your data live to lead your competition. Instead of wondering which model to use, you should start by digging deep in unknown data spaces. As Carl Sagan once said: <em>“Somewhere, something incredible is waiting to be known”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd8918dbc01e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Need for speed: 3 tips to improve Python’s performances]]></title>
            <link>https://dataminimalism.medium.com/need-for-speed-3-tips-to-improve-pythons-performances-0e57ac2200df?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e57ac2200df</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 10:23:55 GMT</pubDate>
            <atom:updated>2024-03-11T10:23:55.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/725/0*33WL1-eXrHhYi4N7.jpg" /></figure><p>Python is the fastest language ever… NOT. We all know that Python is an interpreted language, not a compiled one like C/C++. So in term of speed, it trails quite significantly versus his older brothers/sisters. Nevertheless, Python is one of the most used language in the ML/Cyber community. I cannot blame anybody for this move. I remember when I discovered Python, just not to have to wait for the compiler to finish was a breath of fresh air. But we will want to have performances in our code: the quicker it runs, the more we can achieve for the same unit of time. How to get faster (and at the same time write a more beautiful code)?</p><p>In the following article, I will review 5 tips that will improve your code at a very small cost.</p><h4>How can we measure speed?</h4><p>Python has a nice built-in module to help us quantify our speed gain. With the <strong>timeit </strong>module, you can measure the execution time for a function and a number of iteration. The number of iteration will be handy to remove the additional overhead that can exist and see if our gain of performance is indeed constant as our data get larger and larger.</p><p>To use <strong>timeit</strong>, you can just run the following snippet:</p><pre>import timeit<br><br>print(timeit.timeit(my_function_to_test, number=number_of_iteration))</pre><p>From now on, when we talk about performance improvement, we will refer to the proportional gain in running time between the non optimized and the optimized code snippet.</p><h4>#1 Import only the module you need</h4><p>Every Python code will start with the <strong>import </strong>keyword. Generally, developper will import the whole module and then revert to the . syntax to use only the function they need from this module. There is nothing wrong doing that, except it makes your code execution time around 30% slower.</p><p>The performance decrease arises because when you call a function using . (dot) it will first calls __getattribute()__ or __getattr()__ which then use dictionary operation which costs time. So, try using from module import function.</p><p>We will prove this by putting the two functions below in the <strong>timeit</strong> test.</p><pre>import math<br>def using_dot():<br>    val = math.sqrt(60)<br>    return val<br><br>from math import sqrt<br>def not_using_dot():<br>    val = sqrt(60)<br>    return val</pre><p>We can see on the graph below that indeed our performance is improved by around 30% if we don’t use the dot call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALQSHF6ATwY7ed470D3Xyg.png" /></figure><h4>#2 Use built-in functions</h4><p>Python’s has a lot of built-in functions. They are the best ways to speed up your code. Those functions should be your go-to whenever possible. These built-in functions are well tested and optimized. As per Python’s documentation, here is the list of the built-in functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*xGLwdnbPQPHhq8jEOujL-Q.png" /></figure><p>But why are they fast? Simply because they are implemented in the C language. As before, we’ll write functions to test the speed improvement:</p><pre>def append():<br>    wordlist = [&#39;python&#39;,&#39;is&#39;,&#39;super&#39;,&#39;fun&#39;]<br>    newlist = []<br><br>    for word in wordlist:<br>        newlist.append(word.upper())<br>    return newlist<br><br>def append_map():<br>    wordlist = [&#39;python&#39;,&#39;is&#39;,&#39;super&#39;,&#39;fun&#39;]<br>    newlist = map(str.upper, wordlist)<br>    return newlist</pre><p>I believe the results speak for themselves:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WyU-ysV7iwNfY4WA482tmw.png" /></figure><h4>#3 Don’t use list comprehension, use generator comprehension</h4><p>For once, using a lazy method brings benefits :). List comprehensions are faster than using the loop method. However, the <strong>list comprehension </strong>will create the entire list in memory first while the <strong>generator expression</strong> will create the items on the fly. You can then access the elements thanks to the __next() method. It means that you can run very large and efficient sequences with a simple syntax difference.</p><p>For example, we can take the following functions and see how much gain do we get:</p><pre>def list_comprehension():<br>    return [i ** 2 for i in range(10) if i % 2 == 0]<br><br>def generator_comprehension():<br>    return (i ** 2 for i in range(10) if i % 2 == 0)</pre><p>BAM… The performance improvement is even better than the previous 2 methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dcvHXRtNGv_LUVRquTHSxQ.png" /></figure><p>In summary, there are many different ways to improve your Python code performances. But we have to stress out that performances should not be at the cost of readibility. Keep your code clear, and then improve the parts that you can make more efficient.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e57ac2200df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The most amazing and under used library in python]]></title>
            <link>https://dataminimalism.medium.com/the-most-amazing-and-under-used-library-in-python-f4c3090263c3?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4c3090263c3</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Fri, 08 Mar 2024 13:36:45 GMT</pubDate>
            <atom:updated>2024-03-08T13:36:58.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HxMgcDSqd39A3JZQ.jpeg" /></figure><p>This is the story of the itertools library which is under-used in my humble opinion.</p><p>Python’s itertools library is not just a mere collection of functions; it’s a gateway to a universe where iteration transforms into an art form. Behind its unassuming name lies a treasure trove of tools that empower developers to seamlessly navigate the intricate dance of permutations, combinations, and iterators.</p><p>You can do so many cool things with it and make your code simpler to read and above all more efficient. I’ll introduce 3 basic examples of what can be done with this lightweight and powerful module.</p><h4>#1 Bye bye nested loops</h4><p>We all have faced the infamous nested loop: we have to loop on many iterators and our code becomes a stairway to hell.</p><pre>i = 300<br><br>def nested():<br>    list1 = range(i)<br>    list2 = range(i)<br>    list3 = range(i)<br><br>    # Nested loop<br>    m = 0<br>    for element1 in list1:<br>        for element2 in list2:<br>            for element3 in list3:<br>                m = m + element1 * element2 +element3</pre><p>Thanks to itertool, you can now replace this hellish piece of code into a beautiful one liner:</p><pre>def nested_iter():<br>    list1 = range(i)<br>    list2 = range(i)<br>    list3 = range(i)<br><br>    # Nested loop<br>    m = 0<br>    for a,b, c in product(list1, list2, list3):<br>        m = m + a * b + c</pre><p>True beauty. I have to be honest with you, the speed gain is not massive. In all my tests, I could not present a conclusive piece of content that was a no brainer decision. But what you don’t gain in execution time, you gain it in: code efficiency, development speed and gain in ‘Python master points’. At the end, if execution time is a key problem, I would recommend to avoid Python and look at C or C++ 😊</p><h4>#2 Chaining iterators</h4><p>Another problem we face on our tedious daily life: in you wine cave, you have a lot of bottles and your ledger is organised using different python dictionnaries. As you want to clear your inventory, you need to gather all those info into a single dictionnary. With <strong>itertools</strong>, jsut a simple line of code will render the results expected. Wow!!!</p><pre>import itertools<br><br>ledger1 = {<br>    &#39;chateau margot&#39;:{&#39;year&#39;:1971, &#39;type&#39;:&#39;white&#39;},<br>    &#39;chateau lafitte&#39;: {&#39;year&#39;:1999, &#39;type&#39;:&#39;white&#39;},<br>    &#39;chateau angelus&#39;: {&#39;year&#39;:2000, &#39;type&#39;:&#39;white&#39;},<br>    &#39;chateau cheval blanc&#39;: {&#39;year&#39;:2010, &#39;type&#39;:&#39;red&#39;}<br>}<br><br>ledger2 = {<br>    &#39;chateau figeac&#39;: {&#39;year&#39;:1995, &#39;type&#39;:&#39;red&#39;},<br>    &#39;chateau lafitte&#39;: {&#39;year&#39;:2005, &#39;type&#39;:&#39;red&#39;},<br>    &#39;chateau cheval blanc&#39;: {&#39;year&#39;:2010, &#39;type&#39;:&#39;white&#39;},<br>    &#39;chateau margot&#39;:{&#39;year&#39;:1977, &#39;type&#39;:&#39;red&#39;}<br>}<br><br><br>result = itertools.chain(ledger1.items(), ledger2.items())<br><br>print(dict(result))</pre><p>The astute reader will have noticed that we used the items() method with the dictionnary, but we just passed the list in the other example. Itertools as its name implies needs <strong>iterators</strong> as inputs. In Python, an <strong>iterator </strong>is an object that implements the iterator protocol, consisting of the __iter__() and __next__() methods. A list is not an <strong>iterator</strong>, but an <strong>iterable</strong>. An iterable is an object that can be looped over (with a for loop for example).</p><p>Even if a dictionnary is an iterable, we need to acess both keys and values. The items() view itself is iterable, but it&#39;s not an iterator in the technical sense. It provides a dynamic view of the dictionary&#39;s items.</p><h4>#3 Compress iterators</h4><p>Imagine we have a list of clients, and a list of boolean representing a selector for a gift. How to extract the sub list of winners? The most pythonic way to do is to use a <strong>for … loop</strong> with a <strong>zip function call</strong>.</p><pre>import itertools<br><br><br>clients = [&#39;alice&#39;,&#39;bob&#39;,&#39;bill&#39;,&#39;katy&#39;,&#39;john&#39;,&#39;helen&#39;]<br>winners = [True, True, False, False, True, False]<br><br>winners_list = []<br><br>for client, win in zip(clients, winners):<br>    if win:<br>        winners_list.append(client)<br><br>print(winners_list)</pre><p>It works as the output are our winners: [‘alice’, ‘bob’, ‘john’].</p><p>Now, let’s replace this by a single itertools call:</p><pre>new_winners = itertools.compress(clients, winners)<br><br>print(list(new_winners))</pre><p>You can’t beat this simplicity. The result is the same but look at this beauty.</p><h4>Summary</h4><p>This article is a simple introduction to what can be achieved with a line of code using <strong>itertools</strong>. There are so many functions like filterfalse, isslice,repeat, groupby, permutations… There is probably no limits to what can be achieve to make our code more readable and more efficient.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4c3090263c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visualizing port scanning with scapy]]></title>
            <link>https://dataminimalism.medium.com/visualizing-port-scanning-with-scapy-0e8a54df07bd?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e8a54df07bd</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Fri, 01 Mar 2024 16:50:46 GMT</pubDate>
            <atom:updated>2024-03-01T19:52:59.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*ljay3Oz0oXBbWYad.jpg" /><figcaption>You can scan any port with scapy</figcaption></figure><p>Thanks to scapy, we can understand what happens under the hood of tools like nmap. We can see the actual handshake happening right in front our eyes.</p><h4>You talkin’ to me?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*CAC9AjZuRBf2hZDC.gif" /></figure><p>To scan for open ports on a server, we need few stuff: a server (it can be physical or virtual), and services that are acutally running on this machine.</p><p>On my virtual machine, I have few services running and I can monitor which services are actively LISTENING on certain port by typing the command:</p><p><em>netstat -ltpnd</em></p><p>If you Debian or Ubuntu machine does not have the package installed, simply run</p><p><em>sudo apt install net-tools</em></p><p>The result can of the command can be seen below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*f7JzsHlrAV_WLIvXk1NAWQ.png" /><figcaption>Open ports actively listening on a local machine</figcaption></figure><p>We have many services that could be of interest like port 1514, 1515, 9200…</p><p>I don’t name those services, but you can try to let me know which one they are in the comment section (nothing to win I m sorry :) ).</p><h4>TCP Handshake</h4><p>So we now know that we have some opened ports but that would not be the case of an attacker. How would he/she find those open ports? He/she will take benefit of the TCP handshake.</p><p>The figure below explains quite clearly what happens when a connection is created between a client and a server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AkbFWt2XHQqYQ7ia.png" /></figure><p><strong>Step 1</strong>. The client sends a SYN request to the Server</p><p><strong>Step 2</strong>. The Server (who is listening on this port) will return a SYN-ACK answer</p><p><strong>Step 3</strong>. The connection will be established once the Client sends back a ACK reply.</p><p>Very simple 3 steps process, but let’s try to use it to our advantage and to visualize it we’ll use the amazing package called <a href="https://scapy.net/">scapy</a>.</p><p><strong>A simple SYN request</strong></p><p>As we understand the TCP handshake, we know that if we send a SYN request we will receive a SYN-ACK reply (if the server is listenning on this port — aka the port is open).</p><p>Let’s try with the opened port 1514.</p><pre>from scapy.all import *<br><br>ip = &quot;xxx.xxx.xxx.xxx&quot;<br>port = 1514<br><br>syn = IP(dst=ip) / TCP(dport=port, flags=&quot;S&quot;)<br><br>ans, unans = sr(syn, timeout=2, retry=1)<br><br>for sent, recv in ans:<br>    print(recv[TCP].flags)</pre><p>We will receive a flag SA, which is the shorten version of SYN-ACK.</p><p>Hurra, we can scan ports. Hold on a minute, what if I do the same request on port 1516 which is closed.</p><p>This time the answer is RA, or RST-ACK, which is a clear answer that the port is closed (RST stands for RESET).</p><h4>How to be stealthy while scanning?</h4><p>So we sent some packets and received a SYN-ACK answer for the opened ports. If we leave it like this, wihtout replying, the server will assume the packet has been dropped and will keep resending it. This will probably alert a SOC analyst looking at the network traffic.</p><p>One way to be stealthy is to reply to the SYN-ACK packet (yes it sounds crazy). The usual answer would be to use a ACK packet but this is not convenient as we would have to close the connection. And since I am lazy, I prefer to go the easier route.</p><p>The solution is simply to send a RST packet — aka just forget about it.</p><pre>from scapy.all import *<br><br>ip = &quot;xxx.xxx.xxx.xxx&quot;<br>port = 1514<br><br>syn = IP(dst=ip) / TCP(dport=port, flags=&quot;S&quot;)<br><br>ans, unans = sr(syn, timeout=2, retry=1)<br><br>for sent, recv in ans:<br>    <br>    if recv[TCP].flags == &quot;SA&quot;:<br>        print(f&quot;Port {sent.dport} is opened. Sending RST packet&quot;)<br>        syn = IP(dst=ip) / TCP(dport=port, flags=&quot;R&quot;)<br><br>        ans_rst, unans_rst = sr(syn, timeout=2, retry=1)</pre><h4>Stealthy? Really?</h4><p>When we say stealthy, we don’t mean completely hidden. The packets can still be seen on a tool like wireshark.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*J63sbe6zZu7S6STKc4Ph2w.png" /><figcaption>We can see the packets on wireshark</figcaption></figure><p>The good news is we know our scanner is working as it should be. The bad news is we know where to look to see our trace (but hey, it should help us to know what to do to remove our footprints).</p><p>In another article, we can go through other scanning techniques, UDP port scanning… The sky is our limit.</p><p>As usual, if you liked the article, don’t be shy an clap as much as you want, or even comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e8a54df07bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When faster is not better: Password strengthening with salt and streching]]></title>
            <link>https://dataminimalism.medium.com/when-faster-is-not-better-password-strengthening-with-salt-and-streching-0e900a27c464?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e900a27c464</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 13:00:19 GMT</pubDate>
            <atom:updated>2024-02-29T13:00:19.994Z</atom:updated>
            <content:encoded><![CDATA[<p>In our daily life, we are always look for more speed: faster internet, faster cars,… There is a tiny part in our universe where faster is not actually better but worse. This is the world of password encryption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/0*KAWpc1mKVt5zZ59i.jpg" /></figure><p>In this article, we will review how the password should be protected and why we tend to use slower algorithm to do so. We’ll create a small example in python to appreciate the ins and outs of a package like <a href="https://pypi.org/project/bcrypt/"><strong>bcrypt </strong></a>(you should use a specialized package for your password protection and not rewrite you own. This exercice is only for my fun and understanding).</p><h4>Most common passwords</h4><p>At the time of writing (2024), we live in an era where most of the population are well educated to the risk of cybersecurity. Most of us know that our data are in danger of being stolen, which can have a dreadful effect on our life. This is why most of passwords are well chosen to be hard to break. Let me introduce you to the list of the most common passwords in 2024:</p><ol><li>123456</li><li>123456789</li><li>admin</li><li>Qwerty</li><li>welcome</li><li>Password</li><li>Password1</li><li>p@ssw0rd</li><li>12345</li><li>Qwerty123</li><li>1q2w3e</li><li>12345678</li><li>111111</li><li>1234567890</li><li>Q2w3e4r5t</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/0*227XnIT2iSl4RXm1.jpg" /></figure><p>Yes, this is true: 123456 is still the most common password today. You question why we try to get to pass the OSCP.</p><p>But this is a clear example on why we need to make our passwords more secure. I’ll pass on the policies we could put in pace (more characters, special characters,…) to focus on the backend, what is done after the user has registered to our great service.</p><h4>Hashing: a one way function to a better security</h4><p>Hashing is a process of converting input data (often referred to as a message) into a fixed-size string of characters, which is typically a hash value or hash code. The output, known as the hash, is a unique representation of the input data. Hash functions are designed to be one-way functions, meaning that it should be computationally infeasible to reverse the process and obtain the original input from the hash.</p><p>Normally hash functions are free of collisions (it happens when 2 different strings have the same hash function — we can see that it could be a problem specially in password storage). It is important to note that MD5 is now considered unsecure as it has a collision problem.</p><p>In Python, you can easily get hash functions like SHA256 using the hashlib package.</p><pre>import hashlib<br><br>s = b&quot;this is a simple tect&quot;<br>print(f&quot;hash: {hashlib.sha256(s).hexdigest()}&quot;)</pre><p>The resulting hash is 9adc03554d7c2f49c7a10d67ab6e6bea244fecb006cac8250f41245eb2b4d30a, which is much longer than our input value. This characteristic will be of interest to increase our security.</p><h4>Salting</h4><p>Salting a password is a technique used to enhance the security of stored passwords in a database. The process involves adding a random and unique piece of data, known as a “salt,” to each user’s password before hashing it (more on this after).</p><p>As we have seen, 123456 is still the most used password in the world. If Alice and Bob have the same password, when we save it into the database, the chain of characters would be the same (no randomness). Hence an attacker could access Alice’s account by matching it with Bob’s password (if he knows it). Now imagine if Bob is a security guard and Alice the CEO. We could imagine that the attacker could target Bob to learn his password, and then he could get access to the company most valuable assets.</p><pre>import hashlib<br><br>#Alice and Bob share the same password<br>alice_password = b&quot;123456&quot;<br>bob_password = b&quot;123456&quot;<br><br>#In database, we store the hash of the passwords<br>print(f&quot;Alice&#39;s password hash: {hashlib.sha256(alice_password).hexdigest()}&quot;)<br>print(f&quot;Bob&#39;s password hash: {hashlib.sha256(bob_password).hexdigest()}&quot;)</pre><p>We can see, as we don’t have randomness, both hashes are the same, so access to an account gives us access to the other one.</p><p><strong>Alice’s password hash</strong>: 8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92<br><strong>Bob’s password hash</strong>: 8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92</p><p>So we need to add this level of randomness by adding a unique piece of data at the end of each passwords.</p><pre>import string<br>import random<br><br># Define a function to randomize our salts<br>def random_salt(length=10):<br>    return &#39;&#39;.join(random.choices(string.ascii_uppercase + string.ascii_lowercase+string.digits, k=length))<br><br># Create the salts<br>salt_alice = random_salt()<br>salt_bob = random_salt()<br><br>print(f&quot;Alice&#39;s salt: {salt_alice}&quot;)<br>print(f&quot;Bob&#39;s salt: {salt_bob}&quot;)<br><br># Salting the passwords<br>def password_salting(password, salt):<br>    return bytes(password) + bytes(salt.encode(&#39;utf-8&#39;))<br><br>alice_salted_password = password_salting(alice_password, salt_alice)<br>bob_salted_password = password_salting(bob_password, salt_bob)<br><br>print(f&quot;Alice&#39;s salted password hash: {hashlib.sha256(alice_salted_password).hexdigest()}&quot;)<br>print(f&quot;Bob&#39;s salted password hash: {hashlib.sha256(bob_salted_password).hexdigest()}&quot;)</pre><p>We can see the output of the salt for each of Alice and Bob (please note that if you run the code, you won’t find the same strings, because of its randomness).</p><p><strong>Alice’s salt</strong>: xRKzjJG4rc<br><strong>Bob’s salt</strong>: MIo131UxAL</p><p>And if we rehash the passwords, they are now saved as different even if both of them are 123456. We have increased (a bit) the security of our data.</p><p><strong>Alice’s salted password hash</strong>: dc6306af99f589b6eec06bd29eb8d61863a054a7161abf29d3206aba7d7379d6<br><strong>Bob’s salted password hash</strong>: ba391ec639fe9b497729987304b279fab981be444e78598dffead3d3c7648c87</p><p>Good, but as usual, it is not enough. As attackers are getting better and better every day, and as the machines are getting faster and faster every day, we still need to improve.</p><h4>Key stretching</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*loklhXbiWG8pU4gz.jpg" /></figure><p>When you hear streching, you think about the exercices you were forced to do at the end of your PE class. That is not from the truth. The primary goal of key stretching is to make it computationally more expensive and time-consuming for attackers to guess or brute-force the original key or password. It adds a layer of complexity to the process of deriving the key, making it more resistant to various types of attacks.</p><p>The basic idea behind key stretching is to apply a one-way function (our hash function) multiple times to the original key or password. This process generates an extended or “stretched” key, which is then used for encryption or other cryptographic purposes. The repetition of the one-way function increases the computational effort required to derive the original key. In other words, it is more painfull for the attackers (told you this is not that different from the PE class).</p><pre>def key_stretching(salted_password, rounds=5):<br>    h = salted_password<br>    for i in range(rounds):<br>        h = hashlib.sha256(h).hexdigest()<br>        h = bytes(h.encode(&#39;utf-8&#39;))<br>    return h<br><br><br>alice_password_stretched = key_stretching(alice_salted_password)<br>bob_password_stretched = key_stretching(bob_salted_password)<br><br>print(f&quot;Alice&#39;s stretched password hash: {alice_password_stretched}&quot;)<br>print(f&quot;Bob&#39;s stretched password hash: {bob_password_stretched}&quot;)</pre><h4>Why you should not use SHA256</h4><p>SHA is built for speed. The goal of key stretching is to make life difficult for the attackers. So contrary to our daily life, you want our algorithm to be relatively slow. This is why you should use a special algorithm like bcrypt to encode your passwords.</p><p>If you enjoy the series of articles, please follow me to receive my latest publication.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e900a27c464" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dillie-Hellman Key Exchange with Python or “How to exchange symmetric keys securely”]]></title>
            <link>https://dataminimalism.medium.com/dillie-hellman-key-exchange-with-python-or-how-to-exchange-symmetric-keys-securely-855688944116?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/855688944116</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Wed, 28 Feb 2024 10:47:59 GMT</pubDate>
            <atom:updated>2024-02-28T10:51:56.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HHffxII9hwoiId8s.jpg" /><figcaption>Securely exchanging keys is paramount in symmetric encryption</figcaption></figure><p>Being able to exchange a symmetric key without sending it.</p><h4>Symmetric encryption</h4><p>Symmetric encryption, also known as secret-key encryption, operates on the fundamental principle of using a single secret key for both the encryption and decryption processes. This shared key acts as a digital lock and key, ensuring that only authorized parties with the correct key can unlock and access the protected information. While the concept may seem straightforward, the intricate algorithms and methodologies behind symmetric encryption are complex and robust, making it an indispensable tool in the cybersecurity arsenal.</p><h4>The weak point</h4><p>As the key is the same for encryption and decryption, it is of utmost importance to keep it as secret as possible. But then, you also need to be able to share it with the recipient of the message so you can transfer him the requested information.</p><p>The good old way would be to pass it hand to hand, on a medium of our choice (generally encrypted, but then how to decrypt it :) ?). This might have been a solution in Middle Ages, but in our over connected world, this seems impractical. Symmetric encryption is used with protocols like TLS. Every time a secured connection is started, client and server agree on a secret key to encrypt the traffic. This key is valid during the session only.</p><p>To solve this problem, we can thank Whitfield Diffie and Martin Hellman who in 1979 found a solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/0*-8VSKhLzIpNxFOKp" /><figcaption>Whitfield Diffie and Martin Hellman</figcaption></figure><h4>Dillie Hellman algorithm</h4><p>The magic of the algorithm is to use math in order to get the same key while keeping some of the information secret. We will not dwelve into the maths behind it, but we’ll look at a simple implementation in python (don’t use this one in your projects).</p><p>For people interested in cryptography, the usual suspects are called Alice and Bob (better than calling them A and B).</p><p>So the first thing Alice and Bob do is to agree on 2 numbers: one big prime number <strong>p</strong>, and a generator <strong>g</strong>. Those numbers are exchanged in the clear as it does not really matter for the rest of the algorithm.</p><pre>#Generate random prime p<br>p = cun.getPrime(512)<br><br>#Choose a generator<br>g = 5<br>print(f&quot;p = {p}&quot;)<br>print(f&quot;g = {g}&quot;)</pre><p>We have created a Person class so it can encapsulate everything that is being done under the hood.</p><pre>class Person():<br>    def __init__(self, p, g):<br>        self.p = p<br>        self.g = g<br>        self._a = rand.randrange(2, self.p - 1)<br>        self.A = pow(self.g, self._a, self.p)<br><br>    def publicKey(self):<br>        return self.A<br>    ...</pre><p>Once Alice (and Bob) receive those numbers, they will generate a secret random key a.</p><pre>self._a = rand.randrange(2, self.p - 1)</pre><p>Each of them, then calculate a public key A following the formula g^a mod p. In Python, we can simply use the <strong>pow function </strong>to make the calculation for us.</p><p><a href="https://python-reference.readthedocs.io/en/latest/docs/functions/pow.html">pow - Python Reference (The Right Way) 0.1 documentation</a></p><pre>self.A = pow(self.g, self._a, self.p)</pre><p>This public key can be safely exchanged with the other person.</p><pre>alice = Person(p, g)<br>A = alice.publicKey()<br>print(f&quot;Alice public key: {A}&quot;)</pre><p>As an example, here is what the Alice’s public key would look like.</p><p><strong>Alice public key</strong>: 7921768296383848903406641973410462441198790439023684890015017475315615186469545102598902006041191645624700564752016151340490137974144984000953537424943585</p><p>And here is Bob’s.</p><pre>bob = Person(p,g)<br>B = bob.publicKey()<br>print(f&quot;Bob public key: {B}&quot;)</pre><p><strong>Bob public key</strong>: 6124401612592611194566398818489016728292044103102136112639624133266006071841616996671225411468372020681090063228102169225833359033455762359607431790450398</p><p>We can see that both keys are completely different.</p><p>The last step is for each of our participants to exchange those public keys and recompute the shared secret key. It is done by calculating <strong>PubKey^a mod p</strong>.</p><pre> def createSharedSecret(self, public_key):<br>   self._sharedsecret = pow(public_key, self._a, p)</pre><p>If we look at the shared secret for each of Alica and Bob:</p><p><strong>Alice shared secret</strong>: 7210196906067909443440453322159488249064465551125981676562702605885158319673944666358229340009385263166382136763235546223836717395144900677650155687101603</p><p><strong>Bob shared secret</strong>: 7210196906067909443440453322159488249064465551125981676562702605885158319673944666358229340009385263166382136763235546223836717395144900677650155687101603</p><p>We have managed to create a symetric key, exchanged it, without passing all the information needed to generate it: remember that none of Alice no Bob’s secret random key _a was ever transfered.</p><h4>Attacks</h4><p>As you may know, no system nor cryptography algorithm is immune to hacking. The Diffie-Hellman’s algorithm is sensitive to Man In The Middle attacks. If an attacker was able to sneak in the middle of the “discussion” between Alice and Bob, he could intercept all data exchange in the clear (the big prime p and the generator g), and pretend to be the other participant for each Alice and Bob.</p><p>There are solutions to solve this, but this will be part of another article.</p><p>The full code can be found here:</p><p><a href="https://github.com/new2ossec/diffie_hellman.py/blob/main/diffie_hellman.py">diffie_hellman.py/diffie_hellman.py at main · new2ossec/diffie_hellman.py</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=855688944116" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Digital Signature with Python]]></title>
            <link>https://dataminimalism.medium.com/understanding-digital-signature-with-python-9e88bdb64112?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e88bdb64112</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 13:03:48 GMT</pubDate>
            <atom:updated>2024-02-27T18:09:35.390Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lMYQjEYdyyhyopJQ.jpg" /></figure><p>More and more, we are all asked to sign digitally. It can be for a bank document, a contract,… If you live in this day an age, you could have escaped signing electronically a document. But do we know how it works? How do we verify that the document signed has not been tampered with? Enters the notion of Digital Signature.</p><p>In the realm of digital communication and cybersecurity, digital signatures emerge as the guardians of authenticity and integrity. A digital signature is a cryptographic technique that serves as a virtual seal, ensuring the validity and origin of a digital message, document, or transaction. Similar to a handwritten signature, a digital signature uniquely identifies the sender and verifies that the content has not been altered during transit. It involves a complex process where a private key is used to sign the document, and a corresponding public key is utilized for verification. As a cornerstone of secure online transactions and document authentication, digital signatures play a pivotal role in safeguarding the trustworthiness of digital interactions, offering a sophisticated and reliable solution in the ever-evolving landscape of digital communication.</p><p>We will quickly look at how a simple email can be validated using a digital signature and implement a very simple example.</p><h3>Hash functions</h3><p>A hash function is a mathematical function that takes an input (or ‘message’) and produces a fixed-size string of characters, which is typically a hexadecimal number. The output, often referred to as the hash value or hash code, is unique to the input data. One important feature is that hashes have to be unique without collisions (2 different strings should not give the same hash value). This is why today MD5 is considered insecure compared to SHA256 (that we will be using).</p><pre>import hashlib<br><br>def calculateHash(message):<br>    m = hashlib.sha256()<br>    m.update(message)<br>    return m.digest()</pre><h3>Asymmetric encryption</h3><p>We will go into detail about what is asymmetric encryption (maybe we can keep it fora later article). Basically, you have a key which is private to you (the private one, you guessed it) and the public one that you can transfer out in the wild.</p><p>To make it pallatable, let’s imagine you have a friend sleeping at home. In the morning you have to leave early, so you give your friend your public key, so he can lock the door but he cannot open it. You keep the private one with you as you still want to sleep in your bed tonight.</p><pre>from Crypto.Cipher import PKCS1_OAEP<br>from Crypto.PublicKey import RSA<br><br>#Generating private key (RsaKey object) of key length of 1024 bits<br>private_key = RSA.generate(1024)<br>#Generating the public key (RsaKey object) from the private key<br>public_key = private_key.publickey()</pre><h3>Signed Message class</h3><p>For putting all together, we will create a very simple class that will hold woth the message and the Digital Signature. Then this message can be transfered to the recipient. Please note that at no moment, any key is saved in the class, which makes perfect sense from a data security point of view.</p><pre>class SignedMessage:<br>    message :bytes = None<br>    digitalsignature :bytes = None<br><br>    def __init__(self, message: bytes):<br>        self.message = message<br><br>    def _hash_message(self):<br>        # Generate the hash of this message<br>        return calculateHash(self.message)<br>        <br>    def encrypt(self, key):<br>        hash = self._hash_message()<br>        #Instantiating PKCS1_OAEP object with the public key for encryption<br>        cipher = PKCS1_OAEP.new(key=key)<br>        #Encrypting the message with the PKCS1_OAEP object<br>        self.digitalsignature = cipher.encrypt(hash)</pre><p>Now we can test our code. We can see that the message is created, then encrypted thanks to our private key. Once we sent it and the recipient has received it, he can decrypt the signature (which is a hash) and compare it with his own calculation of the hash of the message. If both matches, you can garanty the integrity of the message.</p><pre>#The message to be encrypted<br>message = b&#39;This is the message to be checked for integrity&#39;<br><br>msg = SignedMessage(message=message)<br><br><br>#Generating private key (RsaKey object) of key length of 1024 bits<br>private_key = RSA.generate(1024)<br>#Generating the public key (RsaKey object) from the private key<br>public_key = private_key.publickey()<br><br><br># Calculating the digital signature<br>msg.encrypt(key = public_key)<br>print(f&quot;Digital Signature: {msg.digitalsignature}&quot;)<br><br># The message is still clear<br>print(f&quot;Message: {msg.message}&quot;)<br><br>#Instantiating PKCS1_OAEP object with the private key for decryption<br>decrypt = PKCS1_OAEP.new(key=private_key)<br>#Decrypting the message with the PKCS1_OAEP object<br>decrypted_message = decrypt.decrypt(msg.digitalsignature)<br><br># We recalculate the hash of the message using the same hash function<br>calcHash = calculateHash(msg.message)<br><br>checkIntegrity(calcHash, decrypted_message)</pre><p>You can get the full code in my repo here</p><p><a href="https://github.com/new2ossec/digitalsignatures/blob/main/digital_signature.py">digitalsignatures/digital_signature.py at main · new2ossec/digitalsignatures</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e88bdb64112" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get poor following financial advices found on internet]]></title>
            <link>https://dataminimalism.medium.com/how-to-get-poor-following-financial-advices-found-on-internet-a0451283387c?source=rss-15c396bcea9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0451283387c</guid>
            <category><![CDATA[financial-freedom]]></category>
            <category><![CDATA[passive-income]]></category>
            <category><![CDATA[options-trading]]></category>
            <dc:creator><![CDATA[Data Minimalism]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 07:21:57 GMT</pubDate>
            <atom:updated>2024-01-26T07:21:57.414Z</atom:updated>
            <content:encoded><![CDATA[<h4>The danger of selling options to earn passive income</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lm3Ai23vwNKIhYAg.jpg" /></figure><h4>The simple pitch: sell options, get passive income</h4><p>Youtube, TikTok even here… You can find so many articles/videos nowadays about how to get a passive income trading options and GPT. When you look at the content, it looks enticing: not too much work, and you can rack $1,000 a month simply. It sounds too good to be true. Here is the hard truth: <strong>IT IS</strong>.</p><p>Financial markets are hard. You have a massive competition from people much more clever than you (and I), with very deep pockets. Technology investments in Investment Banks are in billions of dollars. You think you can beat them with your laptop at the coffee table? Rethink carefully.</p><h4>How easy it is to make money selling options!</h4><p>Selling put is simple. You sell the contract, you earn the premium. But do you really know your risk? Doing so, you have an unlimited loss.</p><p>Tou can cash 5 USD by selling this contract. It is very close to expiry and you have the strike (the level at which you contractually accepted to sell the stock) is a bit out of the money at 172.500 (AMD was trading at 178 at the time).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*Hxu9xQsDcY68tXrpgHBGjA.png" /><figcaption>AMD Put price on 24th Jan 2024</figcaption></figure><p>What could go wrong? If you look in the past few days, AMD went up from 165 to 185, so a gain of 20 USD. It is not unthinkable that it could revert to this level in the same amount of time. At 165 USD, your option position would loose you 7.5 USD, so a total loss of 2.5 USD. And this is just a mean reversion problem. Imagine if the market were to tank (this is not a question of if, but more a question of when).</p><h4>Yeah, but look how much money I made</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*53K5fM9XBeBX0nj3" /></figure><p>This is the beauty with selling naked options. It works… until it does not. There is a common saying in financial markets: selling naked options is like picking up pennies in front of a steamroller. This is a disaster waiting to happen. The problem, you only hear about the “succesfull” ones (I have used brackets as there is never any official bank statement showing that it actually worked).</p><h4>This is not financial advice</h4><p>This is the first sentence of those kind of article. But I am sorry to say to the writers: unfortunatelly it is. Financial markets are regulated, for a reason: you touch to consumer finances which needs to be protected. Not everybody is Warren Buffet. So from the moment you explain how to make passive income using your super duper GPT engine, I am sorry to say you are giving financial advice. Otherwise it would be so easy: not regulations, no exams to pass… Life would feel a sweet dream working in finance.</p><h4>Conclusion and thoughts</h4><p>The dream selling business is Earth old. It can take a lot of different forms. In the past years, Crypto was all the rage, with exactly the same pitch. Now we have a combo of GPT and selling options. If you want to lose your shirt this way, don’t come back saying you were not warned. But before you go there, please consider what I wrote earlier and don’t go this rabbit hole that can only end up in tears, suffering and despair.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0451283387c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>