<?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 B N on Medium]]></title>
        <description><![CDATA[Stories by B N on Medium]]></description>
        <link>https://medium.com/@b-n?source=rss-07ceb64bf54d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by B N on Medium</title>
            <link>https://medium.com/@b-n?source=rss-07ceb64bf54d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:49:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@b-n/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[How Salted Hashes Protect Our Passwords]]></title>
            <link>https://medium.com/@b-n/how-salted-hashes-protect-our-passwords-940137be1210?source=rss-07ceb64bf54d------2</link>
            <guid isPermaLink="false">https://medium.com/p/940137be1210</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[passwords]]></category>
            <category><![CDATA[hashing-algorithm]]></category>
            <dc:creator><![CDATA[B N]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 10:48:56 GMT</pubDate>
            <atom:updated>2024-10-20T19:41:20.228Z</atom:updated>
            <content:encoded><![CDATA[<p>A password is worth a lot these days. As more and more aspects of life have been integrated into digital systems, often online ones, the need to ensure security of such systems has become more pressing. With a password you can access almost every facet of your life such as your school, work, taxes, social life, entertainment, the list goes on. Therefore, it’s vital that passwords do what they’re supposed to do: affirm that the identity of the person trying to access the account is its owner. Otherwise, we would have no hope of implementing systems that deal with sensitive data digitally.</p><p>So how exactly are passwords, the most basic building block of digital security, properly protected?</p><h3><strong>The Problem with Possessing Plain Passwords</strong></h3><p>One might think the solution is obvious, just keep the passwords stored safely away in some place where no one unauthorised can access them, however, this poses some problems.</p><p>Let’s say, Google stores all the passwords for Gmail accounts on a private database that only they have access to. Yet, even the most secure databases are breached from time to time, and in the case of such a breach, that means that every single Gmail password and by extension every Gmail account is now vulnerable and may be logged in to by a bad actor.</p><p>While this may initially seem like a stretch, it’s worth mentioning that this has happened across the globe to both government authorities and private companies for many reasons such as inside jobs, hacking, security vulnerabilities, or even something as simple as accidentally publishing records. In fact, Gmail itself has suffered a data breach in the past resulting in almost 5 million passwords being leaked, and at least 20 significant data breaches have already been reported this year alone<a href="#Bookmark1">[</a>1].</p><p>Thus, we can’t rely on the security of our databases alone and we need to employ greater measures to ensure that even if our data is exposed, the passwords remain uncompromised.</p><h3><strong>Hashing — <em>A Handy Helper</em></strong></h3><p>Let’s first go over some desirable attributes of a system that we could use to store passwords securely:</p><p>· It allows us to <strong>verify</strong> whether the password entered is correct.</p><p>· We can store a <strong>representation of a password</strong>, rather than the password itself.</p><p>· A bad actor <strong>cannot infer the original password from our representation</strong> of it.</p><p>· Each representation of a password should be <strong>unique</strong>.</p><p>Hashing is a solution that bears all of those characteristics. A hash or a hash value, is a unique, fixed-length value produced by a hashing algorithm. Many different hashing algorithms exist, and you may have heard of some of the most common ones, SHA (Secure Hashing Algorithm) or MD5 (Message Digest 5).</p><p>Hashes are deterministic, meaning that with the same input (in our case a password), it will always produce the same output (a hash value). Yet despite this, we cannot deduce our input given our output.</p><p>Let’s illustrate this with an example using SHA2–256, a commonly used hashing algorithm.</p><blockquote>Input: pass1234!<br> Output: fe6b8c6dc4602d8229a7b2b3f7c2f4da7ab9055e23b12ae00db0dd201351b6c2</blockquote><p>Now let’s try this with a different input.</p><blockquote>Input: pass1235!<br> Output: 38b73fce848c23f1b26dfec53b233772dfe6e064d20c6683925464a27325b2b8</blockquote><p>Any change in the input, big or small, will result in a drastic change in the output. And regardless of our input we also can see that the output is of the same length (64 characters in this case).</p><blockquote>Input: pass1234!<br> Output: fe6b8c6dc4602d8229a7b2b3f7c2f4da7ab9055e23b12ae00db0dd201351b6c2</blockquote><p>And of course, identical input produces identical output, though no two inputs should produce the same output<a href="#Bookmark2">[2]</a>.</p><h3><strong>Hashing — <em>Under the Hood</em></strong></h3><p>How can it be possible to produce a fixed-length, unique, irreversible output for any input? It doesn’t sound very intuitive, nonetheless good hashing algorithms have impressively managed to adequately satisfy these requirements while remaining incredibly quick.</p><p>Firstly, to produce fixed-length outputs, hashing algorithms divide input data into equal size parts or blocks, the exact size of each block depending on the algorithm, for example, SHA-1 has blocks that have 512 bits (64 bytes) each (which can equate to 32 or 64 characters depending on the encoding of the characters).</p><p>Each block is run through a mathematical hash function to produce a hash value for each block and lastly the hash values are combined into one final hash value so that the length remains fixed for each hash. For larger input sizes the process may need to be repeated multiple times. And if the last block of input data is not the same length as the rest, it may be padded artificially so that the block sizes are all identical<a href="#Bookmark3">[3]</a>.</p><p>The diagram below should illustrate how this typically works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*Y7g92s6cbD4Y4Muk2clUig.png" /></figure><p>This method also gives rise to a phenomenon aptly called the <em>Avalanche Effect</em>. Recall how in our example earlier, even a small change in our input resulted in a completely different output like how a seemingly insignificant disturbance in the snow on a mountain can result in a devastating avalanche. Thus, every single character in our input is significant.</p><p>What about our <em>mathematical hash function</em>? Typically, hashing algorithms will use what is called a one-way hash function. These functions are easy to calculate the output given a certain input, but intractable to get the input from the output. Calculating the output could take a fraction of a second whereas calculating the input from the output may take months. Imagine mixing together two liquids, it can easily be accomplished in seconds. On the other hand, trying to separate the liquids is almost impossible. These one-way hash functions operate similarly<a href="#Bookmark4">[4]</a>.</p><h3><strong>Hashing — <em>An Impregnable Stronghold?</em></strong></h3><p>Is hashing a perfect solution? Does it absolutely secure our passwords from being reverse engineered? Well, it depends on the situation.</p><p><strong>Brute Forcing Weak Passwords</strong></p><p>The strength of your password matters greatly, let’s go over why.</p><p>Firstly, to differentiate between strong and weak passwords, a weak password may be a commonly used phrase like <em>password123,</em> a date of birth, a password consisting of only numbers or only lowercase letters, a short password, and so on. A strong password should contain letters (both upper and lowercase), numbers, special characters and be generally random and impersonal.</p><p>This is key because weak passwords can be brute forced. Recall that hashes are easy to calculate but difficult to reverse engineer. If we have the hash of a password, we can try every possible combination of inputs through the hash algorithm that was used to generate the hash and see which input produces the same hash. Now with a long password containing different types of characters this is utterly infeasible as it will take even the most powerful supercomputers thousands of years, but with a short password with, say only numbers, this is a simple task for a computer.</p><p><strong>Dictionary Attacks</strong></p><p>Another technique that may be used to discover weak passwords is a dictionary<em> </em>attack that works by checking the hashes produced by commonly used passwords. This may be a birthday, name, phrase. Some wordlists exist that contain many such passwords, a notable one being <em>rockyou.txt</em> that is included in Kali Linux installations, a commonly used operating system for ethical hacking<a href="#Bookmark5">[5]</a>. Thus, if we have a bunch of hashes, we can run through the passwords in a wordlist to see if any of the passwords in the list were used to generate the hashes.</p><p><strong>Rainbow Table Attacks</strong></p><p>An alternative to dictionary attacks are rainbow table attacks. A rainbow table is created by taking a bunch of potential passwords and hashing them. The plain text password and hash value are stored in the table. Then a reduction function is applied to the hash value (it could be as simple as taking the first 8 characters of the hash for example), then the result of that reduction function is hashed to generate a new pair of plain text and hash. This process is repeated several times to create a chain of hashes and plain texts. Lastly, many chains are created with unique starting plain text passwords.</p><p>Then since all the processing is done beforehand, to crack passwords we only need to check the hash value against the last hash value in each chain. If there is a match, then we can find the password by getting the plain text associated with that hash. Otherwise, we can take the password hash, apply our reduction function to that hash to generate a new pair of plain text and hash. Then repeat the process of checking the last hash in each chain and work through the chain to find the actual password. The diagram below illustrates this process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*KI4eun99pHqj5TRoH8feVA.png" /></figure><p>Rainbow values take longer to set up and consume a lot of storage space, but they can serve as a very quick method to get a password from a hash if it exists in the rainbow table<a href="#Bookmark6">[6]</a>.</p><p>It’s a good idea to use a variety of strong passwords so that in the case of a leak, your password won’t be compromised (although you should still change passwords associated with any leaks to guarantee security).</p><p><strong>Collision</strong></p><p>Another issue that may arise is that of collision. Collision occurs when multiple inputs share the same output, in other words when multiple passwords produce the same hash value. We said earlier that hashing algorithms should produce unique output, and this usually holds for good algorithms yet is not a guarantee.</p><p>To visualise this imagine you have 11 balls and 10 buckets. You want to put one ball into each bucket but after placing 10 balls into each bucket, you have one ball left over. So, one bucket ends up having two balls. This is called the pigeonhole principle.</p><p>Since hashes are of a fixed output it means that there are a finite number of possible hashes. However, our inputs can have varying lengths, possibly longer than the hash. It follows that there are more possible inputs than possible outputs meaning that collision exists for some inputs. Hashing algorithms strive to be collision resistant, which means that they try to minimise the possibility of running into collisions.</p><p>If a hash value is discovered, and a bad actor wants to discover the original password. If collision has occurred, there exist multiple passwords that could produce the hash value and it doesn’t actually matter which is used, since what is checked is the resultant hash and not the password itself.</p><h3><strong>Salted Hashes — <em>Seasoning our Solution</em></strong></h3><p>Hashing may not be an absolute guarantee, but with good password hygiene they are a sufficient solution. If you’re still not convinced, there are additional measures that are commonly employed to further protect our passwords. Just as any good hashbrown is seasoned with salt, so too can we season our hash values with salt to improve their security.</p><p>A salt is a random sequence of characters that is added to the password when generating the hash. The hash value and salt are both stored on a database so that we don’t have to remember the salt, just the password. This additional randomness means that even identical passwords with different salts produce different hashes rendering dictionary attacks and rainbow table attacks ineffective as the passwords in the dictionary no longer give the correct hash and the rainbow tables would need to be unfeasibly massive to have any significant impact<a href="#Bookmark7">[7]</a>.</p><h3><strong>Some Final Thoughts</strong></h3><p>While salted hashes certainly serve as secure authentication, they are not a substitute for diligence or a reason for carelessness. So much of the world operates through digital systems and we should be taking every measure to ensure that our accounts and data are safe.</p><p>Now that we’ve seen how even complex solutions like hashing algorithms can be susceptible to attack when dealing with weak passwords, we can appreciate the measures taken to protect against attack, they’re not just there to be tedious! Proper password hygiene as well as opting for multi-factor authentication, biometrics, etc., are all worthwhile investments in your own security.</p><p><strong>References</strong></p><p>1. <em>List of data breaches — Wikipedia</em>. Available at: <a href="https://en.wikipedia.org/wiki/List_of_data_breaches">https://en.wikipedia.org/wiki/List_of_data_breaches</a> (Accessed: 3 October 2024).</p><p>2. Sammons, J., The basics of digital forensics: the primer for getting started in digital forensics. Chapter 3, pp.88–117. Syngress (2014).</p><p>3. <em>What Is Hashing? An Explainer.</em> (2024). Available at: <a href="https://www.criipto.com/blog/what-is-hashing">https://www.criipto.com/blog/what-is-hashing</a> (Accessed: 3 October 2024).</p><p>4. <em>What is One Way Function in Cryptography?</em> <em>GeeksforGeeks (2024)</em>. Available at: <a href="https://www.geeksforgeeks.org/what-is-one-way-function-in-cryptography/">https://www.geeksforgeeks.org/what-is-one-way-function-in-cryptography/</a> (Accessed: 8 October 2024).</p><p>5. <em>wordlists | Kali Linux Tools. Kali Linux</em>. Available at: <a href="https://www.kali.org/tools/wordlists/">https://www.kali.org/tools/wordlists/</a> (Accessed: 8 October 2024).</p><p>6. <em>Understanding Rainbow Table Attack.</em> <em>GeeksforGeeks (2018)</em>. Available at: <a href="https://www.geeksforgeeks.org/understanding-rainbow-table-attack/">https://www.geeksforgeeks.org/understanding-rainbow-table-attack/</a> (Accessed: 8 October 2024).</p><p>7. <em>What is a Salted Secure Hash Algorithm ? — Security Wiki</em> <em>Secret Double Octopus</em>. Available at: <a href="https://doubleoctopus.com/security-wiki/encryption-and-cryptography/salted-secure-hash-algorithm/">https://doubleoctopus.com/security-wiki/encryption-and-cryptography/salted-secure-hash-algorithm/</a> (Accessed: 8 October 2024).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=940137be1210" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>