<?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"><channel><title><![CDATA[🌗  Moon Blog]]></title><description><![CDATA[Writing about Cloud Computing and Tech Concepts]]></description><link>https://mooon.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 18 Oct 2026 16:27:28 GMT</lastBuildDate><atom:link href="https://mooon.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Password Hashing - A must-known concept for developers!]]></title><description><![CDATA[Have you recently created an account on an online platform?
If so, do you think those websites store your passwords as-it-is in their databases?
The answer is probably not. In today's technological era, this is a very silly mistake a website can do. ...]]></description><link>https://mooon.hashnode.dev/password-hashing-a-must-known-concept-for-developers</link><guid isPermaLink="true">https://mooon.hashnode.dev/password-hashing-a-must-known-concept-for-developers</guid><category><![CDATA[Hashing]]></category><category><![CDATA[Python]]></category><category><![CDATA[Security]]></category><category><![CDATA[privacy]]></category><category><![CDATA[development]]></category><dc:creator><![CDATA[Deepak Soni]]></dc:creator><pubDate>Tue, 21 Mar 2023 13:18:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1679402362790/80011d69-3192-4f93-a386-e18faeeb5cd4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you recently created an account on an online platform?</p>
<p>If so, do you think those websites store your passwords as-it-is in their databases?</p>
<p>The answer is probably not. In today's technological era, this is a very silly mistake a website can do. So, how do they store your passwords? And... What's the need for Hashing your passwords?</p>
<p>After reading this blog post, you'll find out the answer to most of your questions related to "Password Hashing". And if you're a developer, you must learn this concept.</p>
<h3 id="heading-the-problem"><strong>The Problem</strong></h3>
<p>When you register your account on a new website, that website stores your username and password along with some other information in its databases. Without that, the website cannot log you in when you visit next time.</p>
<p>So, the question is "Is it secure to store your password as plain text?".</p>
<p>No, it's not! There's a possibility that their employees can read your passwords which can be a threat to your privacy. Also, in case the website suffers from a data breach, your passwords can get exposed to hackers, who can then log into your other social media accounts which share the same password.</p>
<h3 id="heading-the-solution"><strong>The Solution</strong></h3>
<p>The solution is to not store passwords as plain text. There should be a way that your passwords can be converted into something no one can understand and is still unique so that websites can verify your passwords.</p>
<p>But... how is that even possible?</p>
<h1 id="heading-hashing">Hashing</h1>
<p>Hashing is a technology that uses special algorithms to convert your sensitive data into something gibberish.</p>
<p>This gibberish text cannot be translated back into the original text. So, no one knows what the original text was.</p>
<p>Now, let's try solving our problem with <strong>Hashing</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1679399108347/28363397-e141-4680-b1c7-bd5358929600.png" alt class="image--center mx-auto" /></p>
<p>What we can do is convert our passwords into 'Hashes', and then store them in the database. This can be depicted as:</p>
<ol>
<li><p>The server gets your password as <strong>"my_password"</strong>.</p>
</li>
<li><p>It converts your password into a Hash.</p>
</li>
<li><p>The hash looks like this: <strong>"qi8H8R7OM4xMUNMPuRAZxlYUNMPuRA".</strong></p>
</li>
<li><p>Finally, the server stores it in the database.</p>
</li>
</ol>
<p>When you log in next time with your new password, the server will generate a hash for your new password and compare it with the original password's hash. If the hash matches, the password is correct. If not, it's incorrect.</p>
<p>Wow! We've found the solution!</p>
<blockquote>
<p><strong>NOTE:</strong> Hashing is irreversible. It means, after converting your password into a hash, it's impossible to get back the original text.</p>
</blockquote>
<h3 id="heading-irreversible">Irreversible</h3>
<p>Because of such nature, if a data breach occurs, all the passwords are pretty safe as the hackers only got the hashes, not the passwords.</p>
<h1 id="heading-hashing-using-python">Hashing using Python</h1>
<p>Read this simple Python Script that converts a password into its hash using the 'Hashlib' Library.</p>
<pre><code class="lang-python"><span class="hljs-comment"># Import hashlib library</span>
<span class="hljs-keyword">import</span> hashlib

<span class="hljs-comment"># This is your password</span>
password = <span class="hljs-string">"mypassword"</span>

<span class="hljs-comment"># Encode your password to utf-8 (it's mandatory)</span>
encoded_password = password.encode(<span class="hljs-string">"utf-8"</span>)

<span class="hljs-comment"># Generate hash for the encoded password</span>
hashed_password = hashlib.sha256(encoded_password)

<span class="hljs-comment"># Convert the generated hash into text (so that we can print it)</span>
hash_string = hashed_password.hexdigest()

<span class="hljs-comment"># Print the hash text</span>
print(hash_string)
</code></pre>
<pre><code class="lang-bash">Output: 89e01536ac207279409d4de1e5253e01f4a1769e696db0d6062ca9b8f56767c8
</code></pre>
<p>Here are some points to note:</p>
<ul>
<li><p>No need to install the 'hashlib' library, as it's already installed by default.</p>
</li>
<li><p>The text must be encoded into "UTF-8" before hashing.</p>
</li>
<li><p>I've used SHA-256 Hashing Algorithm, which is considered much more secure. But you can use any algorithm of your choice.</p>
</li>
</ul>
<h2 id="heading-thanks-for-reading">Thanks for reading! ❤️</h2>
<p>This blog has covered the basics of password hashing. Yet, there's so much more to learn. If you're interested in hearing more about password hashing, please leave a comment!</p>
<p>Also, I'm going to write more blogs on this topic. So make sure you've signed up for the newsletter and followed me!</p>
<p>Thanks for your time!</p>
]]></content:encoded></item></channel></rss>