<?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[Git for Beginners]]></title><description><![CDATA[Git for Beginners]]></description><link>https://gitforbeginnerbylalit.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 11:10:43 GMT</lastBuildDate><atom:link href="https://gitforbeginnerbylalit.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[JWT Explained Simply — What It Is, How It Works, and Why It Matters]]></title><description><![CDATA[JSON Web Tokens sound scary at first. They're not. This guide breaks down everything from structure to security pitfalls.
1. What is JWT?
JWT stands for JSON Web Token. It is a compact, self-contained]]></description><link>https://gitforbeginnerbylalit.hashnode.dev/jwt-explained-simply-what-it-is-how-it-works-and-why-it-matters</link><guid isPermaLink="true">https://gitforbeginnerbylalit.hashnode.dev/jwt-explained-simply-what-it-is-how-it-works-and-why-it-matters</guid><category><![CDATA[JWT token,JSON Web,Token,Token authentication,Access token,JSON token,JWT security,JWT authentication,Token-based authentication,JWT decoding,JWT implementation]]></category><category><![CDATA[#JWTAuthentication]]></category><category><![CDATA[JWT]]></category><category><![CDATA[JWT token security]]></category><category><![CDATA[securityawareness]]></category><category><![CDATA[Security]]></category><category><![CDATA[JWT authentication]]></category><category><![CDATA[backend developments]]></category><category><![CDATA[authentication]]></category><dc:creator><![CDATA[Lalit Gujar]]></dc:creator><pubDate>Fri, 13 Mar 2026 19:52:32 GMT</pubDate><content:encoded><![CDATA[<p>JSON Web Tokens sound scary at first. They're not. This guide breaks down everything from structure to security pitfalls.</p>
<h2>1. What is JWT?</h2>
<p><strong>JWT</strong> stands for <strong>JSON Web Token</strong>. It is a compact, self-contained way to securely transmit information between two parties — like a <em>server</em> and a <em>client</em> (your browser or mobile app).</p>
<p>Think of it like a <strong>digital ID card</strong>. When you log in to a website, the server gives you this token. You carry it with every future request, so the server knows who you are — without having to ask you to log in again.</p>
<blockquote>
<p>Note : JWT is encoded, not encrypted. Anyone who has the token can read its contents — so never store sensitive data like passwords inside it.</p>
</blockquote>
<h2>2. Why do we use JWT?</h2>
<p>Before JWT, most apps used <strong>sessions</strong>. The server stored your login state in a database. That works, but it does not scale well when millions of users are logged in.</p>
<p>JWT solves this with three key properties:</p>
<ul>
<li><p><strong>Stateless</strong> — The server does not need to store anything. All information is inside the token itself.</p>
</li>
<li><p><strong>Self-contained</strong> — The token carries its own data and its own signature for verification.</p>
</li>
<li><p><strong>Compact</strong> — It is small in size, so it can be sent easily via HTTP headers or cookies.</p>
</li>
</ul>
<p>Common use cases include:</p>
<ul>
<li><p>Authorization (stay logged in after refreshing the page)</p>
</li>
<li><p>Information exchange between services</p>
</li>
<li><p>Single Sign-On (SSO) — log in once, use multiple apps</p>
</li>
</ul>
<h2>3. The 3-Part Structure</h2>
<p>A JWT looks like this:</p>
<pre><code class="language-plaintext">eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiS2FscGVzaCJ9.xMp4_signature_here
</code></pre>
<p>you can genrate this key using this command :</p>
<pre><code class="language-shell">node -e "console.log(require('crypto').randomBytes(32).toString('hex'));"
</code></pre>
<p>It has exactly 3 parts, separated by dots:</p>
<blockquote>
<p>Part 1 : Header</p>
<p>Token type &amp; signing algorithm (e.g. HS256)</p>
</blockquote>
<blockquote>
<p>Part 2 : Payload</p>
<p>Your actual data — user ID, role, expiry time</p>
</blockquote>
<blockquote>
<p>Part 3 : Signature</p>
<p>Proof the token was not tampered with</p>
</blockquote>
<p>Each part is <strong>Base64URL encoded</strong>. The signature is generated using a secret key only the server knows. If anyone changes the payload, the signature breaks — and the server rejects the token.</p>
<h2>4. How it actually works</h2>
<p>Here is the simple flow:</p>
<ol>
<li><p>User logs in with email + password.</p>
</li>
<li><p>Server verifies credentials and creates a JWT using <code>jwt.sign()</code>.</p>
</li>
<li><p>Server sends the token to the client.</p>
</li>
<li><p>Client stores the token (more on where in the Precautions section).</p>
</li>
<li><p>For every future request, the client sends the token in the header.</p>
</li>
<li><p>Server verifies the token using <code>jwt.verify()</code> and reads the payload.</p>
</li>
</ol>
<p>![](<a href="https://cdn.hashnode.com/uploads/covers/695771ceabd7802ad48d9f7f/5965091f-1179-4c8e-bfe2-69649e183a64.png">https://cdn.hashnode.com/uploads/covers/695771ceabd7802ad48d9f7f/5965091f-1179-4c8e-bfe2-69649e183a64.png</a> align="middle")</p>
<blockquote>
<p>jwt.sign() vs jwt.verify()</p>
<p><code>jwt.sign(payload, secret)</code> creates a new token. <code>jwt.verify(token, secret)</code> checks if it is valid and returns the original payload.</p>
</blockquote>
<h2>5. Code Example (Node.js)</h2>
<p>Install the library first:</p>
<pre><code class="language-shell">npm install jsonwebtoken
</code></pre>
<p>Creating a token:</p>
<pre><code class="language-javascript">const jwt = require('jsonwebtoken');

const secret = process.env.JWT_SECRET; // store in .env, never hardcode

const payload = { id: 101, name: 'Kalpesh', role: 'user' };

const token = jwt.sign(payload, secret, { expiresIn: '1h' });

console.log(token); // send this to the client
</code></pre>
<p>Verifying a token:</p>
<pre><code class="language-plaintext">try {
  const decoded = jwt.verify(token, secret);
  console.log(decoded); // { id: 101, name: 'Kalpesh', role: 'user', iat: ..., exp: ... }
} catch (err) {
  console.log('Invalid or expired token');
}
</code></pre>
<h2>6. Access Token vs Refresh Token</h2>
<p>Most real apps use two tokens together. Here is the difference:</p>
<table>
<thead>
<tr>
<th>Property</th>
<th>Access Token</th>
<th>Refresh Token</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Lifetime</strong></td>
<td>Short — 15 minutes to 1 hour</td>
<td>Long — 7 to 30 days</td>
</tr>
<tr>
<td><strong>Purpose</strong></td>
<td>Authenticate API requests</td>
<td>Generate new access tokens</td>
</tr>
<tr>
<td><strong>Storage</strong></td>
<td>Memory or HttpOnly Cookie</td>
<td>HttpOnly Cookie only</td>
</tr>
<tr>
<td><strong>If stolen</strong></td>
<td>Attacker has a very small window before it expires</td>
<td>Can be used to stay logged in — protect carefully</td>
</tr>
</tbody></table>
<p>The combination of both lets users stay logged in for days — without having to re-enter their password — while keeping the security window small.</p>
<h2>7. Common Errors</h2>
<blockquote>
<p><strong>JWT Malformed</strong></p>
<p>Token does not follow the 3-part (header.payload.signature) format. Usually caused by a corrupt or incomplete token string.</p>
</blockquote>
<blockquote>
<p><strong>Token Expired</strong></p>
<p>The <code>exp</code> claim in the payload has passed. You need to issue a new access token using the refresh token.</p>
</blockquote>
<blockquote>
<p><strong>Invalid Signature</strong></p>
<p>Payload was tampered with, or the token was signed with a different secret. Always reject this immediately.</p>
</blockquote>
<blockquote>
<p>Invalid Algorithm</p>
<p>Token header says <code>alg: none</code> — a known attack. Always enforce the algorithm on your server side.</p>
</blockquote>
<h2>8. Security Precautions</h2>
<p>JWT is powerful, but easy to misuse. Watch out for these:</p>
<ol>
<li><p><strong>Do not store tokens in localStorage :</strong> localStorage is accessible to any JavaScript running on your page. If there is an XSS vulnerability, attackers can steal the token. Use an HttpOnly Cookie instead — JavaScript cannot touch it.</p>
</li>
<li><p><strong>Never trust the</strong> <code>alg: none</code> <strong>header</strong> : Some old libraries accepted tokens with no signature algorithm — meaning no verification at all. Always enforce a specific algorithm like HS256 or RS256 on your server.</p>
</li>
<li><p><strong>Use strong, secret keys:</strong> Weak secrets like "password" or "secret123" can be cracked using common word lists. Use a long, random string stored in environment variables — never hardcoded in source code.</p>
</li>
<li><p><strong>Do not include sensitive data in the payload:</strong> JWT is encoded, not encrypted. The payload can be decoded by anyone with the token. Never store passwords, credit card numbers, or private data inside it.</p>
</li>
</ol>
<blockquote>
<p>⚠️ <strong>Need encryption?</strong></p>
<p>If you really must send sensitive information inside a token, use <strong>JWE (JSON Web Encryption)</strong> instead of plain JWT. JWE encrypts the payload so it is not readable without the private key.</p>
</blockquote>
<h2>9. Quick Recap</h2>
<p>Everything you need to remember</p>
<ul>
<li><p>JWT = compact, self-contained token for authentication and information exchange.</p>
</li>
<li><p>3 parts: Header · Payload · Signature — all Base64URL encoded, separated by dots.</p>
</li>
<li><p>JWT is <strong>encoded, not encrypted</strong> — never store sensitive data in it.</p>
</li>
<li><p>Use <code>jwt.sign()</code> to create, <code>jwt.verify()</code> to validate.</p>
</li>
<li><p>Access tokens are short-lived. Refresh tokens are long-lived and stored in HttpOnly cookies.</p>
</li>
<li><p>Store tokens in HttpOnly cookies, never in localStorage.</p>
</li>
<li><p>Always enforce the signing algorithm and use a strong secret key.</p>
</li>
</ul>
<p>That is everything you need to get started with JWT. The best way to solidify this is to build a small login system yourself — create a token on login, verify it on protected routes, and refresh it when it expires. You will understand it deeply once you have done it hands-on.</p>
<hr />
<blockquote>
<p>Written by <a href="https://www.linkedin.com/in/lalitgujar/">lalit gurjar</a> · JWT Notes to Blog · March 2026</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Introduction about git]]></title><description><![CDATA[Git is a key tool in today's software development. Whether you're a student, beginner, or professional developer, knowing Git helps you handle code well, work with others, and keep track of changes. This blog explains Git from the basics in simple la...]]></description><link>https://gitforbeginnerbylalit.hashnode.dev/introduction-about-git</link><guid isPermaLink="true">https://gitforbeginnerbylalit.hashnode.dev/introduction-about-git</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Git]]></category><category><![CDATA[Gitcommands]]></category><category><![CDATA[GitHub]]></category><dc:creator><![CDATA[Lalit Gujar]]></dc:creator><pubDate>Fri, 02 Jan 2026 09:42:30 GMT</pubDate><content:encoded><![CDATA[<p>Git is a key tool in today's software development. Whether you're a student, beginner, or professional developer, knowing Git helps you handle code well, work with others, and keep track of changes. This blog explains Git from the basics in simple language with practical examples.</p>
<h1 id="heading-what-is-git">What is Git ?</h1>
<p>Git is a <strong>distributed version control system (VCS)</strong>.</p>
<p>Simply put, Git helps you <strong>track changes in your files</strong> (especially code) and <strong>manage different versions</strong> of a project.</p>
<ul>
<li><p>Every developer has a <strong>complete copy</strong> of the project on their own computer.</p>
</li>
<li><p>You can save your progress, return to older versions, and try out new ideas safely.</p>
</li>
<li><p>Git works on your computer, so you don’t need the internet for basic tasks.</p>
</li>
</ul>
<p>Git was created by <strong>Linus Torvalds</strong> (the creator of Linux) to manage large codebases efficiently.</p>
<h1 id="heading-why-git">Why Git ?</h1>
<p>Git is popular because it solves many real-world development issues:</p>
<ul>
<li><p><strong>Version control</strong>: Keeps a record of changes and lets you go back to old versions.</p>
</li>
<li><p><strong>Collaboration</strong>: Many developers can work on the same project without messing up each other's work.</p>
</li>
<li><p><strong>Branching</strong>: Test new features or ideas without changing the main code.</p>
</li>
<li><p><strong>Backup</strong>: Your code history is safe even if something goes wrong.</p>
</li>
<li><p><strong>Industry standard</strong>: Works with platforms like GitHub, GitLab, and Bitbucket.</p>
</li>
</ul>
<h1 id="heading-basic-git-and-important-key">Basic Git and important key</h1>
<h2 id="heading-arepository">a)Repository</h2>
<p>A <strong>repository</strong> is a folder that Git keeps track of.<br />It includes:</p>
<ul>
<li><p>Your project files</p>
</li>
<li><p>A hidden <code>.git</code> directory (holds Git history and information)</p>
</li>
</ul>
<p>There are two kinds:</p>
<ul>
<li><p><strong>Local repository</strong>: On your computer</p>
</li>
<li><p><strong>Remote repository</strong>: On servers like GitHub</p>
</li>
</ul>
<h2 id="heading-b-working-directory">b) Working Directory</h2>
<p>The <strong>working directory</strong> is where you normally edit files, and changes are <strong>not tracked</strong> until you inform Git.c) Staging Area</p>
<h2 id="heading-d-commit">d) Commit</h2>
<p>A <strong>commit</strong> is a snapshot of your project at a specific time, with each commit having a unique ID (hash) and a message describing the change, acting like a <strong>save point</strong>.</p>
<h2 id="heading-e-branch">e) Branch</h2>
<p>A <strong>branch</strong> is a separate line of development, typically with the default branch being <code>main</code> or <code>master</code>, and is used to develop features or fix bugs independently.</p>
<h2 id="heading-f-head">f) HEAD</h2>
<p><strong>HEAD</strong> points to the <strong>current commit or branch</strong> you are working on.It tells Git where you are in the project history.</p>
<h1 id="heading-common-git-commands">Common Git Commands :</h1>
<pre><code class="lang-plaintext">git init // Initialize a Repository

git status // Check File Status

git add file.txt // Add Files to Staging Area

git add . // Add all Files to Staging Area

git commit -m "message" // Commit Changes

git log // View Commit History
git log --oneline // View oneliner Commit History

// Create and Switch Branch
    git branch feature 
    git checkout feature 
    git checkout -b feature

git diff // Check Differences
</code></pre>
<h2 id="heading-git-file-flow">Git File Flow</h2>
<pre><code class="lang-plaintext">Working Directory ----&gt; Staging Area -----&gt; Repository
</code></pre>
<h2 id="heading-local-repository-structure">Local Repository Structure</h2>
<pre><code class="lang-nginx"><span class="hljs-attribute">Project</span> Folder
 |--&gt; .git/
 |--&gt; index.html
 |--&gt; app.js
    ...
</code></pre>
<h2 id="heading-commit-history-flow">Commit History Flow</h2>
<pre><code class="lang-plaintext">Commit A --&gt; Commit B --&gt; Commit C (HEAD)
</code></pre>
]]></content:encoded></item></channel></rss>