<?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 Rashad Aziz on Medium]]></title>
        <description><![CDATA[Stories by Rashad Aziz on Medium]]></description>
        <link>https://medium.com/@rashadaziz?source=rss-4b47f42622cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*netQmL1FtLaMmgta</url>
            <title>Stories by Rashad Aziz on Medium</title>
            <link>https://medium.com/@rashadaziz?source=rss-4b47f42622cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:30:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rashadaziz/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[GoGames: A cute little blog]]></title>
            <link>https://medium.com/@rashadaziz/gogames-a-cute-little-blog-a5488bf1ddf5?source=rss-4b47f42622cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5488bf1ddf5</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Rashad Aziz]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 02:47:17 GMT</pubDate>
            <atom:updated>2024-09-30T02:47:17.912Z</atom:updated>
            <content:encoded><![CDATA[<p>To mark the end of our Android module in my software engineering bootcamp, we were tasked in creating an android app that consumes the <a href="https://www.mmobomb.com/api">MMO Bomb API</a> and were given creative freedom on how the interface should look like. In the spirit of my company, I’ve decided to call the app <strong>GoGames</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4exMEqw00208RcZw-gsWA.png" /><figcaption>GoGames in light mode</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZ4N1ezCYc6kOa_Ye30Rew.png" /><figcaption>GoGames in dark mode</figcaption></figure><h3>Overall Architecture</h3><p>The app was built using the MVVM (Model-View-View Model) architecture where each android activity had a single View Model to represent its current state. This allowed the UI/View layer of the application to be as dumb as possible. All its essentially doing is “observing” the current state of the view model, and reacting/syncing to the state changes accordingly. The business logic is completely separated from the activities and entirely burdened on the view models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBLDhce0UWDvq7vfNj84dw.png" /><figcaption>Overall architecture of the application</figcaption></figure><h3>UI Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a5gTlD4nTeGYAPoEk5IuBA.png" /><figcaption>Main Activity architecture</figcaption></figure><p>The central topic of this application is Recycler Views. It is used extensively in this application. The recycler views make use of View Types in order to decide what View to render in that position. The nested recycler views actually still make use of the same adapter that the parent uses. The detail activity also uses a similar architecture using multiple view types.</p><h3>Testing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATfqG2RR7NS8JlS8pdMwHQ.png" /><figcaption>UI Testing</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*UJfC3PA8xczoyjlfCHNnAg.png" /><figcaption>Repository Testing</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*UJfC3PA8xczoyjlfCHNnAg.png" /><figcaption>ViewModel Testing</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5488bf1ddf5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State Design Pattern: Navigating the State of Confusion]]></title>
            <link>https://medium.com/@rashadaziz/state-design-pattern-navigating-the-state-of-confusion-78f50bd5572f?source=rss-4b47f42622cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/78f50bd5572f</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[design-pattern-kotlin]]></category>
            <dc:creator><![CDATA[Rashad Aziz]]></dc:creator>
            <pubDate>Fri, 27 Sep 2024 02:34:28 GMT</pubDate>
            <atom:updated>2024-09-27T02:34:28.002Z</atom:updated>
            <content:encoded><![CDATA[<p>In software engineering, our programs can usually be defined as finite state machines. The main idea is that, at any given moment, there’s a <em>finite</em> number of <em>states</em> which a program can be in. Within any unique state, the program behaves differently, and the program can be switched from one state to another instantaneously. However, depending on the current state, the program may or may not switch to a certain state. These switching rules also know as <em>state transitions </em>are what the state pattern attempts to solve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JQ87sSta2T-1-3id.png" /></figure><p>Imagine we have an audio player that can be in one of three states: Playing, Paused, Stopped. The idea of the state pattern is to encapsulate the transitions of each state into the respective concrete states, which share an interface from an abstract state.</p><pre>// Abstract State<br>interface AudioPlayerState {<br>    fun play(mediaPlayer: MediaPlayer)<br>    fun pause(mediaPlayer: MediaPlayer)<br>    fun stop(mediaPlayer: MediaPlayer)<br>}</pre><p>Now, we define all the states that the audio player could be in:</p><pre>// Concrete States<br>class PlayingState : AudioPlayerState {<br>    override fun play(audioPlayer: AudioPlayer) {<br>        println(&quot;audio is already playing.&quot;)<br>    }<br><br>    override fun pause(audioPlayer: AudioPlayer) {<br>        println(&quot;Pausing audio.&quot;)<br>        audioPlayer.setState(PausedState())<br>    }<br><br>    override fun stop(audioPlayer: AudioPlayer) {<br>        println(&quot;Stopping audio.&quot;)<br>        audioPlayer.setState(StoppedState())<br>    }<br>}<br><br>class PausedState : AudioPlayerState {<br>    override fun play(audioPlayer: AudioPlayer) {<br>        println(&quot;Resuming audio.&quot;)<br>        audioPlayer.setState(PlayingState())<br>    }<br><br>    override fun pause(audioPlayer: AudioPlayer) {<br>        println(&quot;audio is already paused.&quot;)<br>    }<br><br>    override fun stop(audioPlayer: AudioPlayer) {<br>        println(&quot;Stopping audio from paused state.&quot;)<br>        audioPlayer.setState(StoppedState())<br>    }<br>}<br><br>class StoppedState : AudioPlayerState {<br>    override fun play(audioPlayer: AudioPlayer) {<br>        println(&quot;Starting audio playback.&quot;)<br>        audioPlayer.setState(PlayingState())<br>    }<br><br>    override fun pause(audioPlayer: AudioPlayer) {<br>        println(&quot;Cannot pause. audio is stopped.&quot;)<br>    }<br><br>    override fun stop(audioPlayer: AudioPlayer) {<br>        println(&quot;audio is already stopped.&quot;)<br>    }<br>}</pre><p>We see here that all the transition logic is encapsulate in each state. If we were to add a new state, we could just create a new concrete state. We can now use these concrete states in the AudioPlayer class:</p><pre>class AudioPlayer {<br>    private var currentState: AudioPlayerState = StoppedState()<br><br>    fun setState(state: AudioPlayerState) {<br>        currentState = state<br>    }<br><br>    fun play() {<br>        currentState.play(this)<br>    }<br><br>    fun pause() {<br>        currentState.pause(this)<br>    }<br><br>    fun stop() {<br>        currentState.stop(this)<br>    }<br>}</pre><p>We see that the audio player (the finite state machine itself) does not need to care how to transition into one state to another. All it knows is what it can do, which is: play, pause and stop the audio.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78f50bd5572f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Thread about Threads in Android]]></title>
            <link>https://medium.com/@rashadaziz/a-thread-about-threads-in-android-3d4af92d5a78?source=rss-4b47f42622cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d4af92d5a78</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[threading]]></category>
            <dc:creator><![CDATA[Rashad Aziz]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 02:48:08 GMT</pubDate>
            <atom:updated>2024-09-26T02:48:08.621Z</atom:updated>
            <content:encoded><![CDATA[<p>In software engineering, a thread is just a basic unit of execution within a process, where it executes a set of instruction sequentially. Multithreading is a model of program execution that allows for multiple threads to be created within a process, executing independently but concurrently sharing process resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/0*xCscyGNaTcY-xgmA.png" /></figure><p>When an Android application is launched, the system creates a thread of execution for the application, called the <em>main thread</em>. This thread is very important, because it is in charge of dispatching events to the appropriate user interface widgets, including drawing events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ccCviUkOcqsvfGzFdDXRbQ.png" /></figure><p>It is also almost always the thread in which your application interacts with components from the Android UI toolkit, which is why the main thread is sometimes called the UI thread. However, under special circumstances, the main thread of an application might not be its UI thread.</p><p>The UI thread of an Android application constantly listens for events by keeping track of the event queue. For example, if a user presses a button on the screen, that event is not directly processed, but rather it is queued to run on the UI thread. If all the events queued beforehand were processed, then that button press event can be responded to, by invoking a callback for example.</p><h3>“Application not responding”</h3><p>What happens if there was an event on the queue that needs to do a long running task such as fetching data from an API?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DaQ0-zY8y_ftq122R81Qqg.png" /></figure><p>This will essentially block the UI thread from responding to any events. Long running tasks like these are usually why your application hangs and eventually deemed as ANR (Application Not Responding) by the Android process manager.</p><h3>Leave it to the workers</h3><p>So, how are applications loading in their data then? Well, Android actually provides us with so-called “worker” threads, that can run concurrently and in the background, separated from the UI thread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ltrMNBEliODnUTLvLzgEAg.png" /></figure><p>With worker threads, the UI thread can just focus on processing events and not worry about long running tasks. Keep in mind however that the Android UI toolkit is not thread-safe. Therfore, there are two rules to Android’s single-thread model:</p><ol><li>Don’t block the UI thread.</li><li>Don’t access the Android UI toolkit from outside the UI thread.</li></ol><pre>fun onClick(v: View) {<br>    Thread(Runnable {<br>        // A potentially time consuming task.<br>        val bitmap = processBitMap(&quot;image.png&quot;)<br>        imageView.post {<br>            imageView.setImageBitmap(bitmap)<br>        }<br>    }).start()<br>}</pre><p>The code snippet above is how worker threads are usually used and how it communicates with the UI thread. The post() method is thread-safe and does not violate Android’s single threaded model since it runs the code inside the block on the UI thread.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d4af92d5a78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What the heck is a Reflection? (in Kotlin)]]></title>
            <link>https://medium.com/@rashadaziz/what-the-heck-is-a-reflection-in-kotlin-fecfe3753896?source=rss-4b47f42622cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fecfe3753896</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Rashad Aziz]]></dc:creator>
            <pubDate>Tue, 24 Sep 2024 19:21:08 GMT</pubDate>
            <atom:updated>2024-09-24T19:21:08.356Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1MyAQzpS46T1MhYZ.png" /><figcaption>source: Disney’s Mulan</figcaption></figure><p>In the context of computer science and programming, <strong>reflection </strong>refers to the ability of a process to examine, introspect and modify its own behavior at runtime. In this blog, we’re going to see how we can perform all sorts of crazy stuff using Kotlin’s reflection features. Note that this list is not exhaustive, but it should give a grasp on how much power (or danger) Kotlin’s reflection features give us.</p><h3>1. Creating Extension Methods</h3><p>A pretty common use case for reflections is to define extension methods for existing classes. This has become common practice for certain use cases and has influenced languages like C# to natively <a href="https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods">support</a> extension methods. Let’s take a look on how we could achieve this in Kotlin.</p><pre>val String.lastChar: Char get() = this[length - 1]</pre><p>The snippet demonstrates how we could extend the existing String object and add a new method called lastChar that, as its name suggests, returns the last character of a String instance. If your IDE is smart enough, your new extension method will appear in your <em>autocomplete </em>and now you will be able to do the following:</p><pre>val myString = &quot;Hello&quot;<br>val lastChar = myString.lastChar // returns &#39;o&#39;<br>val alsoLastChar = String::lastChar.get(myString) // also returns &#39;o&#39;</pre><p>It’s important to note however that creating extension methods should not be the norm. It is only used in certain use cases such as, when we want to extend an object but its closed for extension (final/sealed) and we don’t own the source code.</p><h3>2. Serializing Objects</h3><p>A cool thing we could do using reflections in Kotlin is serializing objects into some other form like a JSON string.</p><pre>val myObject = myClass<br>val properties = MyClass::class.memberProperties // [prop1, prop2, ...]<br>val first = properties.first() // prop1<br>val jsonString = &quot;{ \&quot;${first.name}\&quot;: \&quot;${first.get(myObject)}\&quot; }&quot;</pre><p>The snippet above can be extended to handle the serialization of multiple properties. This is all possible because of Kotlin’s ability to introspect objects during runtime.</p><h3>3. Testing private methods</h3><pre>val someMethod = MyClass::class.java.getDeclaredMethod(&quot;someMethod&quot;)<br>// this will make sure that someMethod is public<br>someMethod.isAccessible = true</pre><p>Finally, we have a really cursed example of leveraging the power of reflections. Here we are treating the method someMethod as a first class object and setting it to be accessible from everywhere, essentially overriding the private modifier we set.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fecfe3753896" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ergonomics for the Overworked Software Engineer]]></title>
            <link>https://medium.com/@rashadaziz/ergonomics-for-the-overworked-software-engineer-ea155320c728?source=rss-4b47f42622cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea155320c728</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ergonomics]]></category>
            <dc:creator><![CDATA[Rashad Aziz]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 19:56:33 GMT</pubDate>
            <atom:updated>2024-09-23T19:56:33.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*nOfaxJasuc9fz3Ob.gif" /><figcaption>source: <a href="https://www.newyorker.com/magazine/2024/04/15/slouch-posture-panic-in-modern-america-beth-linker-book-review">https://www.newyorker.com/magazine/2024/04/15/slouch-posture-panic-in-modern-america-beth-linker-book-review</a></figcaption></figure><p>As software engineers, we often spend most days slouching on our desks coding away and wondering why our code keeps SEGFAULT’ing. After finally pinpointing that the culprit was a nil pointer dereference, you might feel a brief surge of triumph — until you get slapped in the face by a dose of reality: your back is screaming, your wrists are aching, and your eyes are at best rendering at <em>144p</em>. Whilst navigating the seemingly endless maze known as a legacy codebase, we often forget that our bodies need just as much care as our code.</p><p>A <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7586624/">study</a> conducted in India on “the knowledge and practice of Ergonomics among the Software Engineers” found that, among the 403 study participants, 85.6% had musculoskeletal problems. To make it worse, only 9% had adequate ergonomic knowledge and only fewer among them practice it adequately. This blog will outline the common best practice ergonomics to help take care of your body as a software engineer.</p><h3>Eye, Eye Captain</h3><p>Staring at a bright screen for most of your day can take its toll on your eyes, and they are the organs that most people (including me) take for granted. Excessive screen exposure can tire the <a href="https://en.wikipedia.org/wiki/Ciliary_muscle">ciliary muscle</a> in your eyes which causes eye strain. In the long run, its possible that the blue light emitted from your screens can cause long term damage to your eyes, although there hasn’t been any conclusive studies on it <a href="https://www.specsavers.co.uk/glasses/glasses-lenses/do-blue-light-glasses-work?srsltid=AfmBOopPGGNycx0KqNjYCe80P10m700qw2PmbqahrY4CDQLyTsbNUKXT">yet</a>.</p><p>This is why some doctors recommend the <a href="https://www.allaboutvision.com/conditions/refractive-errors/what-is-20-20-20-rule/">‘20–20–20’ rule</a> which states that, for every 20 minutes you stare at a screen, you should look away for 20 seconds, and stare at something 20 feet (6 meters) away. This will relax the strain in your eyes and reduce fatigue. It’s also recommended to keep your screens about 20–30 inches (50–76 centimeters) away at all times. Other than that, always remember to keep yourself hydrated, as this will help keep your eyes from drying out.</p><h3>My neck, my back, debugging code in my stack!</h3><p>For those of you who work with laptops, you might notice that you are constantly tilting you head down for the duration of your coding session. It might seem insignificant but <a href="https://www.news.com.au/technology/gadgets/mobile-phones/this-is-what-looking-down-at-your-phone-does-to-your-spine/news-story/ba751ede763e77086d036f5515de227b">research</a> suggests that even a 15° forward tilt of the neck can double the weight felt by your neck. This means that over time, this position can not only cause you neck and back pain, but affect your posture as well. And unless you want to end up like the <em>Hunchback of Notre Dame </em>you should stop slouching on your desk as it could have adverse effects in the long run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/0*-RN01MjFISMijJFK.jpg" /><figcaption>source: <a href="https://thrivenowphysio.com/the-dangers-of-sitting/">https://thrivenowphysio.com/the-dangers-of-sitting/</a></figcaption></figure><p>To circumvent hurting your neck and your back, you should always try keeping your screen level with your eyes to prevent you from looking down on it. You should also try to keep your neutral sitting position as shown in the preceding figure. A neutral sitting position is one that preserves the three natural curves of the spine and puts the least amount of strain on your back, allowing you to work pain-free longer. But even if we regularly sit with the most perfect posture, it will still take a toll on our spine. Which is why its actually recommended to code/do your work whilst standing up from time to time. <a href="https://uwaterloo.ca/kinesiology/how-long-should-you-stand-rather-sit-your-work-station">Research</a> suggests that the “sweet” spot for a sit-stand ratio ranges from 1:1 to 1:3, meaning that for every 15 minutes of sitting we should stand up for 15 to 45 minutes. This will reduce the load on our spine and also improve our blood flow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea155320c728" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Salty Passwords: How Your Passwords Are Secured in a Database (Or at Least How It Should Be)]]></title>
            <link>https://medium.com/@rashadaziz/salty-passwords-how-your-passwords-are-secured-in-a-database-or-at-least-how-it-should-be-af6dc01aa20c?source=rss-4b47f42622cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/af6dc01aa20c</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Rashad Aziz]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 18:43:57 GMT</pubDate>
            <atom:updated>2024-08-27T18:43:57.957Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wondered what happens after you register an account on that shady cat lovers website listed on the 12th page of your google search results? Specifically, where, and how is your 6-character, 3-number, 1-symbol combination, otherwise known as your <em>password, </em>going to be stored? Ultimately, in one form or the other, your passwords are stored in some kind of database, where it will reside patiently, waiting for a malicious attacker to come and steal it.</p><p>The topic of <strong>secure password storage has been of paramount importance ever since the first websites required users to authenticate their identities</strong>. <a href="https://haveibeenpwned.com/PwnedWebsites">Many websites</a> have felt the harrowing repercussions of neglecting proper password storage over the years. This was mostly due to naively storing passwords in <em>plaintext </em>or poor implementations of <em>cryptographic algorithms </em>used to secure them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*I0TI68VygTZo0ndgNP9Ogw.png" /><figcaption>A naive way of storing passwords</figcaption></figure><p>This blog will educate you on why sometimes having a strong password like hdi91gd8fiubuiu121@#&amp;!@9 is not enough (although still important). What happens if an attacker gains full access to the database, and see hdi91gd8fiubuiu121@#&amp;!@9 listed as the password associated with your account? This is why many developers and engineers are coming up with sophisticated techniques to keep your passwords safe, even in the event of a full database breach. The following sections will try and explain these techniques in an intuitive manner, so you can be <em>somewhat </em>confident that your passwords are safe, in most modern websites at least.</p><h3><strong>Password Hash brown, wait no, Hashing</strong></h3><p>Let’s dive into the crunchy details of password security. Hashing is the process that keeps your credentials safe by transforming your passwords into a <strong>seemingly </strong>random string of characters, essentially obfuscating them. <em>Hashing Algorithms </em>(<a href="https://en.wikipedia.org/wiki/MD5">md5</a>, <a href="https://en.wikipedia.org/wiki/Secure_Hash_Algorithms">SHA</a>, etc.)<em> </em>generates these strings in such a way that it <strong>cannot be traced back to its original input</strong>, in this case, your password. They are also <em>deterministic, </em>meaning that given the same input, these algorithms will <strong>always generate the same output</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kWsKkhEPgPLJK3gohYmZEg.png" /><figcaption>Password Hashing</figcaption></figure><p>BUT, like all things, hashing also has its weaknesses. A major downside to hashing is that some inputs can actually have the same output. This is what is known as a <em>hash collision</em>. The consequences of a hash collision will be discussed in the following sections, but in the meantime lets try and visualize how one can occur with an example of a bad hashing algorithm. Imagine a hashing algorithm that takes in a PIN number as input, and outputs the <strong>sum of the digits</strong> in that PIN number. This is actually a very simple example of a valid hashing algorithm, albeit a very bad one. This algorithm will cause different PIN numbers such as, “1234” and “4321” to map to the same value “10”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZvBfzjXSwROJukible8bA.png" /><figcaption>Hash Collision</figcaption></figure><h3>Attack of the Hash Tables</h3><p>Nowadays, attackers are finding clever ways to circumvent the hashing of passwords. One method commonly used is the <em>Hash Table Attack. </em>A Hash Table Attack is where an attacker generates a table of pre-computed hashes from a list of strings or to be precise, a list of <strong>common known passwords</strong>. This way an attacker can go through this table and find a hash that matches some hash in the compromised database. Of course, the attacker would need to know what kind of hashing algorithm a certain website uses, but as it turns out, this is <a href="https://security.stackexchange.com/questions/180535/how-does-the-attacker-know-what-algorithm-and-salt-to-use-in-a-dictionary-attack/180536#180536">relatively easy</a> to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*BytsJNOGVqwEP852bAUvFQ.png" /><figcaption>Hash Table</figcaption></figure><p>This type of attack gets even easier when the hashing algorithm has a high collision-rate, which we have discussed before. Imagine if ~30% of the time, the hashing algorithm generates the same output given a different input. That means, if an attacker successfully cracks just one of the passwords, it will imply that roughly ~30% of those passwords are also compromised. This is why choosing a strong password is still recommended, as it decreases the chance of it becoming compromised in scenarios like these. However, its not completely foolproof. For example, what if that same strong password was already compromised because another website you used it for stored it in plaintext? Granted, the chances are pretty slim, but given the tendency for us to reuse our passwords, its definitely still uncomfortably high.</p><h3>It’s a bit bland, let’s sprinkle some salt</h3><p>Turns out hashing is not the “end-all be-all” solution for secure password storage. However, it gives us a good base to start with. The main problem with hashing is, although irreversible, attackers can still relatively find easy ways to “reverse” it and crack our passwords. This is made even easier if the hashing algorithm used as a high collision-rate. Imagine if somehow we could come up with a hashing algorithm that is deterministic yet “random”. That way for every password that you make, a unique hash is generated, even if its the same password. This is the gist of what <em>salting </em>password hashes try to achieve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICvve74-XismxUSJURNIVQ.png" /><figcaption>Salted Passwords</figcaption></figure><p>In modern websites, your passwords are usually <em>salted </em>which helps make an attackers life orders of magnitude harder. So what is this “salt” that is sprinkled to your passwords? Basically, for every password we create, a <strong>unique</strong> random string of characters (salt) are appended (or prepended) to your password before it is hashed. This ensures that every password we create has a unique hash, even if its the same password. You might ask, then how do we verify if a user has entered the correct password? Well, that’s simple actually, we just need to store the original salt string along with the hashed value. This seems counterintuitive at first, as we’re giving the attacker half of our password essentially. But remember that each password of each user is given a unique salt. This means that for every password, the attacker must perform a brute-force hash table attack using each corresponding unique salt. This is also assuming that the attacker already has a table of hash values for the password + unique salt combination, which is a big assumption.</p><p>Realistically, an attacker would have to store a table for each possible salt. Let’s put the numbers into perspective. If we were to use a 16 byte = 128 bits salt, that would give us 2¹²⁸ (~340 undecillion) possible salt values, which is 1.7 quadrillion times more than the number of stars in our universe. Each of these salt values would then need to be paired up with the list of common known passwords and hashed. Needless to say, it’ll be a very long day for the attacker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-U7DLuYoiZBIpieSghy4zA.png" /><figcaption>Possible Salt Values vs Number of Stars in Universe</figcaption></figure><h3>So are we safe, forever, basically?</h3><p>As hard as it is to believe, salted passwords is not considered a “<a href="https://adamcaudill.com/2013/05/07/password-hashing-no-silver-bullets/">silver bullet</a>”. When it comes to passwords, a lot of human factors come into play as well, such as the tendency for us to reuse passwords, and how social engineering can make us accidentally reveal passwords explicitly. This is why the industry is <a href="https://www.helpnetsecurity.com/2023/12/21/moving-away-from-passwords/">slowly shifting away from using passwords</a> as an authentication method in favor of more robust methods such as <em>2-Factor Authentication</em>. Nonetheless, I hope this blog has taught you a thing or two on how developers and engineers alike are trying their absolute best to keep your passwords safe, and who knows you might come up with an even better idea.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af6dc01aa20c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>