{"componentChunkName":"component---src-templates-blog-list-template-js","path":"/engineering/20","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"excerpt":"AWS EC2 is a virtual computing environment (known as instances) to develop and deploy applications. To create an EC2 instance in AWS, we…","fields":{"slug":"/engineering/ec2-instance-aws/"},"html":"<p>AWS EC2 is a virtual computing environment (known as instances) to develop and deploy applications. To create an EC2 instance in AWS, we need an active Amazon Web Services account. </p>\n<h2 id=\"ec2-dashboard\" style=\"position:relative;\"><a href=\"#ec2-dashboard\" aria-label=\"ec2 dashboard permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>EC2 Dashboard</h2>\n<p>First, let's login into our AWS account. Once login, we will land on the Management Console page, we can see all the AWS services. </p>\n<p><img src=\"/00b62bc651136276e300af2178f08b67/1_console.webp\" alt=\"AWS Management Console\"></p>\n<p>There is a drop-down on the top left corner, which is one more option to search and browse all the services provided by AWS. You can find <code>EC2</code> under the <code>Compute</code> category.</p>\n<p><img src=\"/cf995d68cacdb4e149eed6e98ca2437b/2_services.webp\" alt=\"AWS Services\"></p>\n<p>Once we click on <code>EC2</code> you will be redirected to the <strong>EC2 Dashboard</strong>. It shows the information related to all the EC2 resources for a specific Region in our account.</p>\n<blockquote>\n<p>Note: If we change the region from the top right corner of the dashboard, it will show the selected region's information. In the below snapshot, we have selected <code>Mumbai</code> region. </p>\n</blockquote>\n<p>There is a button <code>Launch Instance</code> to create a new instance in the selected region on the dashboard's bottom section. </p>\n<p><img src=\"/a8f74d863955c6320c60c0d29a52a72b/3_dashboard.webp\" alt=\"EC2 Dashborad\"></p>\n<h2 id=\"how-to-launch-an-ec2-instance\" style=\"position:relative;\"><a href=\"#how-to-launch-an-ec2-instance\" aria-label=\"how to launch an ec2 instance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to launch an EC2 Instance</h2>\n<p>After clicking the Launch button, we need to select the Amazon Machine Image (AMI) it includes the operating system and applications required to launch an instance. Here we will select the Ubuntu Server 20.04 LTS as shown in the below snapshot.</p>\n<p><img src=\"/c46efcd1445b2e70816a37ff5765b0dc/4_ami.webp\" alt=\"EC2 AMIs\"></p>\n<p>The next step is to choose the type of instance we need. AWS provides many types of instances based on different use cases with various CPU combinations, memory, storage, and networking capacity. We will here select the <code>t2.micro instance</code>, which is a free tier eligible instance.</p>\n<blockquote>\n<p>while writing this tutorial, Amazon provides 750 hours per month of free usage on the t2.micro instance. It makes it very affordable to run small/sample applications for an initial period.</p>\n</blockquote>\n<p><img src=\"/5b219a8dd124e49014949a7934569eb9/5_type.webp\" alt=\"EC2 Types\"></p>\n<p>On the Instance Configuration Details Page, we have options to run more than one instance at once, and there are other configurations regarding roles and access management. We will skip all this and click on the <code>Next: Add Storage</code> button.</p>\n<p><img src=\"/c980178a2bf57114a79b80e1e697dc41/6_configuratio.webp\" alt=\"Configure Instance Details\"></p>\n<p>We can increase or decrease the size of instance storage while creating it; the free tier is eligible upto 30GB; if you need more storage, it will be billed according to <a href=\"https://aws.amazon.com/ebs/pricing/\">Elastic Block Store (EBS) Pricing</a></p>\n<p><img src=\"/af636c41fc75f3e9556d65f0900d2742/7_storage.webp\" alt=\"Storage\"></p>\n<p>On the next screen, we can add tags to our instance and storage; these tags are key-value pair which are very useful to add properties to our resources, especially when we have multiple instances.</p>\n<p><img src=\"/013bb6c580181166d7ee92a32211d45b/8_tags.webp\" alt=\"Tags\"></p>\n<p>We can define the firewall rules in a security group attached to our instance. With the help of these rules, we can control the traffic to our instance.</p>\n<p><img src=\"/542385138ace677410dfae52bef06896/9_security.webp\" alt=\"Security Group\"></p>\n<p>Once we are done with firewall rules, we can review the complete detail of our new instance on a single page, and here we can click <code>Launch</code> button to launch the instance.</p>\n<p><img src=\"/39083c0324aa6fe4c8bafab2ab1002ef/10_review.webp\" alt=\"Review\"></p>\n<p>When we click <code>Launch</code>, it will open a pop-up that will require you to select a pre-existing public-private key-pair or create one to connect to our instance securely. Once you select/download the key, you will be able to launch the instance.</p>\n<p><img src=\"/152f89066e3bcbe121bd4b29152a452b/11_key.webp\" alt=\"Security Key\"></p>\n<p>It will take approximately 5-10 min to launch the instance. Once launched, You can see the list of your running instances by clicking on the <code>Instances</code> button on the left menu.</p>\n<p><img src=\"/693d0043ef65710f306cd757b94d6f4f/12_runnning_instace.webp\" alt=\"Running\"></p>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>As you can see, it is effortless to create a free tier AWS instance to deploy your application. In the upcoming article, we will show you how to deploy an application on the EC2 instance and the best practices.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"November 18, 2020","updated_date":null,"description":"Learn how to create an EC2 (Elastic Compute Cloud) instance in an AWS account in simple and straightforward steps.","title":"How to create an EC2 Instance in AWS","tags":["AWS","DevOps","EC2"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/d8663624ccdd85c88db0a127028ee564/58556/ec2cover.webp","srcSet":"/static/d8663624ccdd85c88db0a127028ee564/61e93/ec2cover.webp 200w,\n/static/d8663624ccdd85c88db0a127028ee564/1f5c5/ec2cover.webp 400w,\n/static/d8663624ccdd85c88db0a127028ee564/58556/ec2cover.webp 800w,\n/static/d8663624ccdd85c88db0a127028ee564/99238/ec2cover.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Puneet Singh","github":"puneetsingh24","avatar":null}}}},{"node":{"excerpt":"What is Git Cherry Pick Git cherry-pick is a powerful command that allows any specific Git commits to be selected by reference and append to…","fields":{"slug":"/engineering/git-cherry-pick/"},"html":"<h2 id=\"what-is-git-cherry-pick\" style=\"position:relative;\"><a href=\"#what-is-git-cherry-pick\" aria-label=\"what is git cherry pick permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Git Cherry Pick</h2>\n<p>Git cherry-pick is a powerful command that allows any specific Git commits to be selected by reference and append to the current working HEAD. The act of picking a commit from a branch and adding it to another is <strong>cherry picking</strong>. For undoing modifications, <code>git cherry-pick</code> can be useful. Say, for example, that a commit is made to the wrong branch unintentionally. You may turn to the right branch and select the commit to where it is supposed to belong. </p>\n<h2 id=\"how-to-use\" style=\"position:relative;\"><a href=\"#how-to-use\" aria-label=\"how to use permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>HOW to use</h2>\n<p>To showcase this, let us assume we have a repository with the following branches:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">alpha - beta - gama - delta   `Master`</span>\n<span class=\"grvsc-line\">     \\</span>\n<span class=\"grvsc-line\">       x - neutron - Ultraviolet `Feature`</span></code></pre>\n<p><code>git cherry-pick commitSha</code></p>\n<p>In this example, commitSha is a reference to commit. Using the git log, you can locate a commit referenced assum we wanted to use commit 'neutron' in master in this example. We make sure that we are working on the master branch first.</p>\n<p><code>git checkout master</code></p>\n<p><code>git cherry-pick neutron</code></p>\n<p>Once executed, our Git history will look like:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">alpha - beta - gama - delta - neutron  `Master`</span>\n<span class=\"grvsc-line\">     \\</span>\n<span class=\"grvsc-line\">       x - neutron - Ultraviolet `Feature`</span>\n<span class=\"grvsc-line\">\t   </span></code></pre>\n<p>The neutron commit has been successfully picked into the feature branch.</p>\n<h2 id=\"when-to-use\" style=\"position:relative;\"><a href=\"#when-to-use\" aria-label=\"when to use permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>WHEN to use</h2>\n<p>git cherry-pick is a useful tool but isn't best practice always. Cherry-picking can trigger duplicate commits, and traditional merges are preferred instead in many situations where cherry-picking would work. Git cherry-pick is a useful option for a few situations. </p>\n<h4 id=\"collaboration\" style=\"position:relative;\"><a href=\"#collaboration\" aria-label=\"collaboration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Collaboration</h4>\n<p>A team will often find individual members working in or around the same code sometimes. Perhaps there is a backend and frontend component of a new product feature. There may be some shared code between two sectors of the product. Perhaps the developer of the backend produces a data structure that will also need to be used by the frontend. In order to select the commit in which this hypothetical data structure was created, the frontend developer could use git cherry-pick. This selection would allow the developer of the front end to continue progress on their project side.</p>\n<h4 id=\"quick-fixes\" style=\"position:relative;\"><a href=\"#quick-fixes\" aria-label=\"quick fixes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Quick fixes</h4>\n<p>When a bug is discovered, it is essential to fix that quickly as possible. For example, let's say a developer has started working on a new feature. During the development of a new feature, they find an existing bug. The developer creates an explicit commit to fix this bug. This new patch commit can be cherry-picked directly to the master branch to quickly fix the bug.</p>\n<h4 id=\"undo-and-restore-commits\" style=\"position:relative;\"><a href=\"#undo-and-restore-commits\" aria-label=\"undo and restore commits permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Undo and restore commits</h4>\n<p>A feature branch can often go stale and not be merged into a master. Often, without merging, a pull request might be closed. Git never sacrifices those commits, and they can be identified and cherry-picked back to life by commands such as git log and git reflog.</p>\n<h2 id=\"other-options\" style=\"position:relative;\"><a href=\"#other-options\" aria-label=\"other options permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Other options</h2>\n<p><strong>-edit</strong>\nPassing the -edit option causes git to trigger a commit message before the cherry-pick process is introduced.</p>\n<p><strong>—no-commit</strong>\nThe —no-commit option executes the cherry-pick, but it transfers the contents of the target commit into the working directory of the current branch instead of making a new commit.</p>\n<p><strong>—the-signoff</strong>\nThe —signoff option adds the signature line 'signoff' to the end of the cherry-pick commit message at the end.</p>\n<p> Git cherry-pick also accepts merge strategy options and conflict resolution as well. Please check the git merge strategy documentation.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","frontmatter":{"date":"November 17, 2020","updated_date":null,"description":"Introduction to Git Cherry-pick and its usages.","title":"How to use Git Cherry Pick","tags":["git"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/7cc5358c073674d856e8ea5cddc47710/58556/cherrypck.webp","srcSet":"/static/7cc5358c073674d856e8ea5cddc47710/61e93/cherrypck.webp 200w,\n/static/7cc5358c073674d856e8ea5cddc47710/1f5c5/cherrypck.webp 400w,\n/static/7cc5358c073674d856e8ea5cddc47710/58556/cherrypck.webp 800w,\n/static/7cc5358c073674d856e8ea5cddc47710/99238/cherrypck.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Abhimanyu Singh Rathore","github":"abhir9","avatar":null}}}},{"node":{"excerpt":"Application Security is one of the primary concerns for a software developer. People trust your application and share sensitive or personal…","fields":{"slug":"/engineering/password-security-best-practices-compliance/"},"html":"<p>Application Security is one of the primary concerns for a software developer. People trust your application and share sensitive or personal information. As a software developer, you need to take care of your application user information security. Authentication and authorization both play critical roles in application security. They confirm the identity of the user and grant access to your website or application.</p>\n<p>The process in which confirm the user's identity and provides access to sensitive information is called authentication. Generally, authentication is done through the email/username/password. Authentication using the password is the older and common way, so passwords are a critical component of user's identity security. Password policy is the front line of defense to protect user identity. However, weak passwords may violate compliance standards. A simple or common password could be reversed engineered back to plaintext and sold on the dark web, or result in a costly data breach if compromised.</p>\n<h3 id=\"why-we-needed-password-policy--compliance\" style=\"position:relative;\"><a href=\"#why-we-needed-password-policy--compliance\" aria-label=\"why we needed password policy  compliance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why We needed Password Policy &#x26; Compliance</h3>\n<p>Password policies and compliance are rules and methods that enforce the user for using a secure and robust password. A billion credentials were stolen last year from multiple data breaches. According to <a href=\"https://enterprise.verizon.com/resources/reports/2017_dbir.pdf\">Verizon's Data Breach Report</a>, 81% of data breaches are caused by compromised, weak, and reused passwords. According to <a href=\"https://www.bbc.com/news/technology-47974583\">National Cyber Security Centre (NCSC)</a> recent analysis, millions of peoples are using easy to guess passwords like <code>123456</code>. Recently a security researcher <a href=\"https://techcrunch.com/2020/10/22/dutch-hacker-trump-twitter-account-password/\">claimed</a> he hacked President Trump's tweeter account by guessing his password <code>maga2020!</code> so now we can understand the need for Password Policy &#x26; Compliance. You can check the top worst passwords list <a href=\"https://www.loginradius.com/blog/identity/worst-passwords-list-2019/\">here</a>.</p>\n<h4 id=\"1-minimum-password-age-policy\" style=\"position:relative;\"><a href=\"#1-minimum-password-age-policy\" aria-label=\"1 minimum password age policy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. Minimum Password Age policy</h4>\n<p>The Minimum password age policy is to decide how many days minimum users must keep a password before changing it. This password policy.</p>\n<h4 id=\"2-enforce-password-history-policy\" style=\"position:relative;\"><a href=\"#2-enforce-password-history-policy\" aria-label=\"2 enforce password history policy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. Enforce Password History policy</h4>\n<p>The \"Enforce password history\" policy is used to make sure the number of unique passwords a user must set before reusing an old password. This is an important policy because password reuse is a common issue – the user feels more comfortable with the old passwords. Using the same password for a long duration for a particular account, it will create a strong chance for the password compromised in some way, such as in a brute force attack. Password age policy shouldn't be efficient until the password history policy. Users must change their password, but they can reuse an old password; the effectiveness of a password age policy is greatly reduced.</p>\n<h4 id=\"3-minimum-password-length-policy\" style=\"position:relative;\"><a href=\"#3-minimum-password-length-policy\" aria-label=\"3 minimum password length policy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. Minimum Password Length policy</h4>\n<p>The Minimum Password Length policy decides the minimum number of characters needed to create a password. Minimum Password Length should be at least eight characters or more. Longer passwords are generally more secure and harder to crack than short ones. For even greater security, you could set the minimum password length to 14 characters.</p>\n<h4 id=\"4-passwords-must-meet-complexity-requirements-policy\" style=\"position:relative;\"><a href=\"#4-passwords-must-meet-complexity-requirements-policy\" aria-label=\"4 passwords must meet complexity requirements policy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. Passwords Must Meet Complexity Requirements policy</h4>\n<p>The Passwords Complexity Requirements policy make sure user shouldn't use basic passwords. Passwords should be a combination of uppercase, lowercase, and numbers also include some special characters. We can set the following policies in the password Complexity Requirements.</p>\n<ul>\n<li>The Passwords shouldn’t contain the user name or name and basic profile fields, such as their first name.</li>\n<li>\n<p>The Password must use following characters combinations </p>\n<ul>\n<li>Uppercase letters </li>\n<li>Lowercase letters </li>\n<li>Non-alphanumeric characters </li>\n<li>(special characters): (~!@#$%^&#x26;*_-+=`|(){}[]:;\"'&#x3C;>,.?/) </li>\n<li>Numberaic characters</li>\n</ul>\n</li>\n</ul>\n<h4 id=\"5-common-password-protection\" style=\"position:relative;\"><a href=\"#5-common-password-protection\" aria-label=\"5 common password protection permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>5. Common Password Protection</h4>\n<p>The users shouldn't use the common passwords, so Restrict the use of common passwords. You can refer to this <a href=\"https://www.loginradius.com/docs/authentication/concepts/common-password/\">document</a> for a common password list maintained by LoginRadius and this list is dynamic, and it gets updated from time to time.</p>\n<h4 id=\"6-dictionary-password-prevention\" style=\"position:relative;\"><a href=\"#6-dictionary-password-prevention\" aria-label=\"6 dictionary password prevention permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>6. Dictionary Password Prevention</h4>\n<p>A Password dictionary is a file that contains a list of potential passwords. This feature prevents your user's from setting a password available in the dynamic password dictionary. We are using this dynamic <a href=\"https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt\">Password Dictionary</a> in the LoginRadius to prevent the use of dictionary passwords.</p>\n<h4 id=\"7-password-audit-policy\" style=\"position:relative;\"><a href=\"#7-password-audit-policy\" aria-label=\"7 password audit policy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>7. Password Audit policy</h4>\n<p>Enabling the Password Audit policy allows you to track all password changes. By monitoring the modifications that are made, it is easier to track potential security problems. This helps to ensure user accountability and provides evidence in the event of a security breach.</p>\n<h4 id=\"password-compliance\" style=\"position:relative;\"><a href=\"#password-compliance\" aria-label=\"password compliance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Password Compliance</h4>\n<p>Password compliance is a set of rules to enhance user's data security by encouraging users to use strong passwords and use them properly.</p>\n<h4 id=\"1-fda-us-food-and-drug-administration\" style=\"position:relative;\"><a href=\"#1-fda-us-food-and-drug-administration\" aria-label=\"1 fda us food and drug administration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. FDA (U.S. Food and Drug Administration)</h4>\n<p>The FDA regulates the set of rules for the food, drugs, biologics, medical devices, electronic products, cosmetics, veterinary products, and tobacco products Industries.</p>\n<p>Passwords for FDA Industry Systems accounts must meet ALL of the following requirements:</p>\n<ul>\n<li>It should be at least 8, but no more than 32 characters.</li>\n<li>It should contain one UPPERCASE letter.</li>\n<li>It should contain one lowercase letter.</li>\n<li>It should contain at least one special character: ~ ! @ # $ % ^ * ( ) _ - + = { } [ ] | : ; \" , ?. Do not use &#x3C;> &#x26; or '.</li>\n<li>It should contain one number digit (numbers).</li>\n</ul>\n<h4 id=\"2-hipaa-health-insurance-portability-and-accountability-act\" style=\"position:relative;\"><a href=\"#2-hipaa-health-insurance-portability-and-accountability-act\" aria-label=\"2 hipaa health insurance portability and accountability act permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. HIPAA (Health Insurance Portability and Accountability Act)</h4>\n<p>The Health Insurance Portability and Accountability Act (HIPAA) enforce a set of rules for sensitive patient data protection. Companies that deal with protected health information (PHI) must ensure HIPAA compliance.</p>\n<ul>\n<li>It should contain both upper and lower case characters (e.g., a-z, A-Z);</li>\n<li>It should contain digits (numbers) and other non-letter characters such as <code>!@#$%^&#x26;*()_+|~-=\\'{}[]:\";&#x3C;>?,./</code>;</li>\n<li>It should be at least 8 characters long;</li>\n<li>It should not be a word in any language, slang, dialect, jargon, etc.; and</li>\n<li>It should not be easily ascertained from the research of publicly available information, such as names of family members, school names, addresses, etc.</li>\n</ul>\n<h4 id=\"3-pci-dss-payment-card-industry-data-security-standard\" style=\"position:relative;\"><a href=\"#3-pci-dss-payment-card-industry-data-security-standard\" aria-label=\"3 pci dss payment card industry data security standard permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. PCI DSS (Payment Card Industry Data Security Standard)</h4>\n<p>PCI is the set of rules or guidelines for the businesses that are dealing with payment card data.</p>\n<ul>\n<li>It should be at least eight characters long.</li>\n<li>It should contain both numeric and alphabetic characters.</li>\n<li>Users should change passwords once every 90 days.</li>\n<li>used to make the sure number of unique passwords a user must set before reusing an old password Password parameter are set to require that new passwords cannot be the same as the four previously used passwords.</li>\n<li>First-time passwords for new users and reset passwords for existing users are set to a unique value for each user and changed after first use</li>\n<li>User accounts are temporarily locked-out after not more than six invalid access attempts.</li>\n<li>Once a user account is locked out, it remains locked for a minimum of 30 minutes or until a system administrator resets the account.</li>\n<li>System/session idle time out features have been set to 15 minutes or less.* Passwords are protected with strong cryptography during transmission and storage.</li>\n</ul>\n<h4 id=\"4-nist-national-institute-for-standards-and-technology\" style=\"position:relative;\"><a href=\"#4-nist-national-institute-for-standards-and-technology\" aria-label=\"4 nist national institute for standards and technology permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. NIST (National Institute for Standards and Technology)</h4>\n<p>NIST creates a set of rules or guidelines for the businesses that are providing services to the federal government. These guidelines to help federal agencies meet the requirements of the FISMA; however, other organizations reference NIST for strong security standards. </p>\n<ul>\n<li>It should be a minimum of eight characters and a maximum length of at least 64 characters </li>\n<li>It may use all special characters but no special requirement to use them</li>\n<li>It should restrict sequential and repetitive characters (e.g., 12345 or aaaaaa)</li>\n<li>It should Restrict context-specific passwords (e.g., the name of the site, etc.)</li>\n<li>It should Restrict commonly used passwords (e.g., p@ssw0rd, etc.) and dictionary wordsRestrict passwords obtained from previous breach corpuses</li>\n</ul>\n<h3 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h3>\n<p>I have explained why we needed a strong password policy &#x26; compliance. It doesn't matter how strong a password you are using, but bad guys are using new methods or technologies for exposing the user data.\nMost of the data breaches are happing because of Common or weak passwords. MFA, passwordless, or one-time password are providing additional security for a user account.  </p>\n<h3 id=\"source\" style=\"position:relative;\"><a href=\"#source\" aria-label=\"source permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Source</h3>\n<p>https<span></span>://www.fda.gov/food/online-registration-food-facilities/random-password-generator-fda-industry-systems</p>\n<p>https<span></span>://uwm.edu/hipaa/security-guidelines/#password</p>\n<p>https<span></span>://pcipolicyportal.com/blog/pci-compliance-password-requirements-best-practices-know/</p>\n<p>https<span></span>://spycloud.com/new-nist-guidelines/</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"November 12, 2020","updated_date":null,"description":null,"title":"Password Security Best Practices & Compliance","tags":["Security","Password","Compliance","Passowrd Policy"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/4e0affaac848158a3cb23d1551a0076e/58556/password-security.webp","srcSet":"/static/4e0affaac848158a3cb23d1551a0076e/61e93/password-security.webp 200w,\n/static/4e0affaac848158a3cb23d1551a0076e/1f5c5/password-security.webp 400w,\n/static/4e0affaac848158a3cb23d1551a0076e/58556/password-security.webp 800w,\n/static/4e0affaac848158a3cb23d1551a0076e/99238/password-security.webp 1200w,\n/static/4e0affaac848158a3cb23d1551a0076e/135cd/password-security.webp 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Vijay Singh Shekhawat","github":"code-vj","avatar":null}}}},{"node":{"excerpt":"What is PGP? PGP (Pretty Good Privacy) is a cryptographic process used to encrypt and decrypt information. It combines concepts from…","fields":{"slug":"/engineering/using-pgp-encryption-with-nodejs/"},"html":"<h2 id=\"what-is-pgp\" style=\"position:relative;\"><a href=\"#what-is-pgp\" aria-label=\"what is pgp permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is PGP?</h2>\n<p>PGP (Pretty Good Privacy) is a cryptographic process used to encrypt and decrypt information. It combines concepts from symmetric and asymmetric key encryption, maintaining some of the best security and usability aspects of both.</p>\n<p>One way PGP can be used is to protect the confidentiality of information. Once the information is encrypted, nobody will be able to decrypt it unless they have the right key. In practice, PGP is commonly used in sending and receiving emails, sharing information on the Dark Web, and others. This is because both on and off the Internet, there are ways to intercept information being sent, making encryption using PGP or similar critical.</p>\n<p>On a high-level the process between a sender and receiver looks like this:</p>\n<ol>\n<li>The recipient generates public and private keys.</li>\n<li>The recipient sends its public key to the sender.</li>\n<li>The sender encrypts the message using the given public key.</li>\n<li>The sender sends the encrypted message to the recipient.</li>\n<li>The recipient decrypts the message using its private key.</li>\n</ol>\n<h2 id=\"pgp-examples-in-nodejs\" style=\"position:relative;\"><a href=\"#pgp-examples-in-nodejs\" aria-label=\"pgp examples in nodejs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>PGP Examples in Node.js</h2>\n<p>Now, let's go over some examples in Node.js using the <a href=\"https://www.npmjs.com/package/openpgp\">openpgp library</a>.</p>\n<ul>\n<li>OpenPGP is a protocol that defines the standards for PGP. OpenPGP.js implements the OpenPGP protocol in JavaScript.</li>\n</ul>\n<p>We'll go over some basic examples and show how to encrypt &#x26; decrypt large files using Node.js streams.</p>\n<p>First, set up your Node.js project and install openpgp.js:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">mkdir pgp-tutorial && cd pgp-tutorial && npm init</span>\n<span class=\"grvsc-line\">npm i openpgp --save</span></code></pre>\n<p>Note: examples use openpgp v4.10.8</p>\n<h3 id=\"generating-keys\" style=\"position:relative;\"><a href=\"#generating-keys\" aria-label=\"generating keys permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generating keys</h3>\n<p>When generating private and public PGP keys with OpenPGP, you can define which curve to use in Elliptic-curve cryptography. In this example, we use Ed25519 for its performance and small key size. For the full list of curves, you can choose from, refer to OpenPGP.js docs.</p>\n<p>You also need to define a passphrase used to decrypt files and the private key. In practice, this should be a strong, randomized secret generated for a single-use.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">// generate-keys.js</span>\n<span class=\"grvsc-line\">const openpgp = require(&quot;openpgp&quot;);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">generate();</span>\n<span class=\"grvsc-line\">async function generate() {</span>\n<span class=\"grvsc-line\">  const { privateKeyArmored, publicKeyArmored } = await openpgp.generateKey({</span>\n<span class=\"grvsc-line\">    userIds: [{ name: &quot;person&quot;, email: &quot;person@somebody.com&quot; }],</span>\n<span class=\"grvsc-line\">    curve: &quot;ed25519&quot;,</span>\n<span class=\"grvsc-line\">    passphrase: &quot;qwerty&quot;,</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\">  console.log(privateKeyArmored);</span>\n<span class=\"grvsc-line\">  console.log(publicKeyArmored);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Running the above gives us our private key:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">-----BEGIN PGP PRIVATE KEY BLOCK-----</span>\n<span class=\"grvsc-line\">Version: OpenPGP.js v4.10.8</span>\n<span class=\"grvsc-line\">Comment: https://openpgpjs.org</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">xYYEX6iKVxYJKwYBBAHaRw8BAQdANJ6JIXuMMZV3NIlwq0POS7xsF2N7+kAE</span>\n<span class=\"grvsc-line\">7KQjAtfIuqj+CQMI4CUgW9jPsGPgJvQnnCWFf1s7lO/5+D5ZQ9JK25fUtmQo</span>\n<span class=\"grvsc-line\">WyHX0Ja1ryOoFnvq7u+7fUC0+RAzt8S1xv3eDzazfgNuLtEmufwMyR6wMi78</span>\n<span class=\"grvsc-line\">Kc0ccGVyc29uIDxwZXJzb25Ac29tZWJvZHkuY29tPsKPBBAWCgAgBQJfqIpX</span>\n<span class=\"grvsc-line\">BgsJBwgDAgQVCAoCBBYCAQACGQECGwMCHgEAIQkQVrbGpNEnCPUWIQQb8YRJ</span>\n<span class=\"grvsc-line\">hw7DjekU68lWtsak0ScI9UM7AQDv4YRbIdU2ErPf8MobreeLiXXjYZ6fas8E</span>\n<span class=\"grvsc-line\">zW0KoTZWEQD+NHDY2YYByMF1mWusPkdPDpyBzqMJrlMeihMzZ+PE8AfHiwRf</span>\n<span class=\"grvsc-line\">qIpXEgorBgEEAZdVAQUBAQdARY37/Vys4Sj6DvwN6TRjxrIqiMIngxQgvOb6</span>\n<span class=\"grvsc-line\">wi+tQzEDAQgH/gkDCJ2xNZ1OXxv94E8fTLQ3gYHFQuebn/PSijD8CqlvHNB/</span>\n<span class=\"grvsc-line\">/Z9sIxSFt7rzorW+9v6Awfe+pQwXW5iEyJkdiGu3BM91GMwMvMmZ+rBNlBvq</span>\n<span class=\"grvsc-line\">iX7CeAQYFggACQUCX6iKVwIbDAAhCRBWtsak0ScI9RYhBBvxhEmHDsON6RTr</span>\n<span class=\"grvsc-line\">yVa2xqTRJwj17W0BAI5MuCWHrqjSRcdjLTwxa++jYv+Yxq4tODj8oh27T86v</span>\n<span class=\"grvsc-line\">AQCfb3lij9JGlIMNDQgceeougl+Lw4Gb0kQCnsNQRggTDw==</span>\n<span class=\"grvsc-line\">=yzT4</span>\n<span class=\"grvsc-line\">-----END PGP PRIVATE KEY BLOCK-----</span></code></pre>\n<p>And the public key:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">-----BEGIN PGP PUBLIC KEY BLOCK-----</span>\n<span class=\"grvsc-line\">Version: OpenPGP.js v4.10.8</span>\n<span class=\"grvsc-line\">Comment: https://openpgpjs.org</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">xjMEX6iKVxYJKwYBBAHaRw8BAQdANJ6JIXuMMZV3NIlwq0POS7xsF2N7+kAE</span>\n<span class=\"grvsc-line\">7KQjAtfIuqjNHHBlcnNvbiA8cGVyc29uQHNvbWVib2R5LmNvbT7CjwQQFgoA</span>\n<span class=\"grvsc-line\">IAUCX6iKVwYLCQcIAwIEFQgKAgQWAgEAAhkBAhsDAh4BACEJEFa2xqTRJwj1</span>\n<span class=\"grvsc-line\">FiEEG/GESYcOw43pFOvJVrbGpNEnCPVDOwEA7+GEWyHVNhKz3/DKG63ni4l1</span>\n<span class=\"grvsc-line\">42Gen2rPBM1tCqE2VhEA/jRw2NmGAcjBdZlrrD5HTw6cgc6jCa5THooTM2fj</span>\n<span class=\"grvsc-line\">xPAHzjgEX6iKVxIKKwYBBAGXVQEFAQEHQEWN+/1crOEo+g78Dek0Y8ayKojC</span>\n<span class=\"grvsc-line\">J4MUILzm+sIvrUMxAwEIB8J4BBgWCAAJBQJfqIpXAhsMACEJEFa2xqTRJwj1</span>\n<span class=\"grvsc-line\">FiEEG/GESYcOw43pFOvJVrbGpNEnCPXtbQEAjky4JYeuqNJFx2MtPDFr76Ni</span>\n<span class=\"grvsc-line\">/5jGri04OPyiHbtPzq8BAJ9veWKP0kaUgw0NCBx56i6CX4vDgZvSRAKew1BG</span>\n<span class=\"grvsc-line\">CBMP</span>\n<span class=\"grvsc-line\">=C6S6</span>\n<span class=\"grvsc-line\">-----END PGP PUBLIC KEY BLOCK-----</span></code></pre>\n<h3 id=\"file-encryption\" style=\"position:relative;\"><a href=\"#file-encryption\" aria-label=\"file encryption permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>File Encryption</h3>\n<p>Now we can start encrypting information.</p>\n<p>Create a text file:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">echo &#39;This file contains secret information&#39; &gt; secrets.txt</span></code></pre>\n<p>Here, we act as the sender who received a public key from the intended recipient. We use their public key to encrypt the confidential information:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">// encrypt-file.js</span>\n<span class=\"grvsc-line\">const openpgp = require(&quot;openpgp&quot;);</span>\n<span class=\"grvsc-line\">const fs = require(&quot;fs&quot;);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const publicKeyArmored = &lt;PUBLIC KEY GIVEN BY RECIPIENT&gt;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">encrypt();</span>\n<span class=\"grvsc-line\">async function encrypt() {</span>\n<span class=\"grvsc-line\">  const plainData = fs.readFileSync(&quot;secrets.txt&quot;);</span>\n<span class=\"grvsc-line\">  const encrypted = await openpgp.encrypt({</span>\n<span class=\"grvsc-line\">    message: openpgp.message.fromText(plainData),</span>\n<span class=\"grvsc-line\">    publicKeys: (await openpgp.key.readArmored(publicKeyArmored)).keys,</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  fs.writeFileSync(&quot;encrypted-secrets.txt&quot;, encrypted.data);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>In the newly created <code>encrypted-secrets.txt</code> file, we have the contents encrypted like so:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">-----BEGIN PGP MESSAGE-----</span>\n<span class=\"grvsc-line\">Version: OpenPGP.js v4.10.8</span>\n<span class=\"grvsc-line\">Comment: https://openpgpjs.org</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">wV4DUsPKVnc3UHMSAQdAey4TJiEOrZQIrx6q2zBLgmPkbnhPMt1WR+jCWX5x</span>\n<span class=\"grvsc-line\">Gn8wEim8W4OhDVMwfhtgVIClBCGPhvdeZ1zvVUAJGDdl8+S+DUynKhPNcN8m</span>\n<span class=\"grvsc-line\">Kb9TRGYs0sAlAaXcTChBHSS5kDHV/8Hgjcn0OIs6v2mbCkz/bHs/shwf8WMI</span>\n<span class=\"grvsc-line\">ov711iEkgcXnXIX+ZDGyDFnAKftoygzAf0aZy82g7ejAD9SX13wNmO6TK8Gw</span>\n<span class=\"grvsc-line\">wr9Xj8F6XBV0yHvdsm2uzRY9W03tTSqAf0anEs+ZWyVR/ha9ddnZJPFKtUbC</span>\n<span class=\"grvsc-line\">BEF4AMavsIN0CcqpA4q69I3E6GEtkAzgBWfJOOO8mQsNQ1vJWcJocinryBE6</span>\n<span class=\"grvsc-line\">Kbhznoe+R69qmUaJXPpe5scF6tfCYuQtPz4uhOljT+OUP6qss5Nz4zBs4JLq</span>\n<span class=\"grvsc-line\">nUlyynLLSSgdVr4Hvg==</span>\n<span class=\"grvsc-line\">=5tyF</span>\n<span class=\"grvsc-line\">-----END PGP MESSAGE-----</span></code></pre>\n<p>Now, as the sender, we can send the encrypted file to the recipient.</p>\n<h3 id=\"file-decryption\" style=\"position:relative;\"><a href=\"#file-decryption\" aria-label=\"file decryption permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>File Decryption</h3>\n<p>Here, we act as the reciever. To decrypt the <code>encrypted-secrets.txt</code> file, we use our private key and passphrase:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">// decrypt-file.js</span>\n<span class=\"grvsc-line\">const openpgp = require(&quot;openpgp&quot;);</span>\n<span class=\"grvsc-line\">const fs = require(&quot;fs&quot;);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const privateKeyArmored = &lt;PRIVATE KEY&gt;</span>\n<span class=\"grvsc-line\">const passphrase = &lt;PASS PHRASE&gt;;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">decrypt();</span>\n<span class=\"grvsc-line\">async function decrypt() {</span>\n<span class=\"grvsc-line\">  const privateKey = (await openpgp.key.readArmored([privateKeyArmored])).keys[0];</span>\n<span class=\"grvsc-line\">  await privateKey.decrypt(passphrase);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  const encryptedData = fs.readFileSync(&quot;encrypted-secrets.txt&quot;);</span>\n<span class=\"grvsc-line\">  const decrypted = await openpgp.decrypt({</span>\n<span class=\"grvsc-line\">    message: await openpgp.message.readArmored(encryptedData),</span>\n<span class=\"grvsc-line\">    privateKeys: [privateKey],</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  console.log(decrypted.data);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Which logs the decrypted file contents:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">This file contains secret information.</span></code></pre>\n<h3 id=\"using-streams-for-large-files\" style=\"position:relative;\"><a href=\"#using-streams-for-large-files\" aria-label=\"using streams for large files permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Using Streams for Large Files</h3>\n<p>If you plan on encrypting or decrypting large files, you won't be able to fit the entire file contents in memory. In this case, you can use Node.js streams.</p>\n<p>Here, we encrypt a large file called <code>dataset-1mill.json</code> using streams:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">encrypt();</span>\n<span class=\"grvsc-line\">async function encrypt() {</span>\n<span class=\"grvsc-line\">  const encrypted = await openpgp.encrypt({</span>\n<span class=\"grvsc-line\">    message: openpgp.message.fromText(fs.createReadStream(&quot;dataset-1mill.json&quot;)),</span>\n<span class=\"grvsc-line\">    publicKeys: (await openpgp.key.readArmored(publicKeyArmored)).keys,</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  let readStream = encrypted.data;</span>\n<span class=\"grvsc-line\">  let writeStream = fs.createWriteStream(&quot;encrypted-dataset.txt&quot;, { flags: &quot;a&quot; });</span>\n<span class=\"grvsc-line\">  readStream.pipe(writeStream);</span>\n<span class=\"grvsc-line\">  readStream.on(&quot;end&quot;, () =&gt; console.log(&quot;done!&quot;));</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>And then, we decrypt the newly created <code>encrypted-dataset.txt</code> using streams:</p>\n<ul>\n<li>Notice that we set the flag allow<em>unauthenticated</em>stream to true, which allows streaming data before the message integrity has been checked. This is because, in our case, our OpenPGP message only has a single integrity tag at the end. This means the entire message gets loaded into memory, and we get a heap out of memory error since our file is too large to fit into memory at once.</li>\n</ul>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">openpgp.config.allow_unauthenticated_stream = true;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">decrypt();</span>\n<span class=\"grvsc-line\">async function decrypt() {</span>\n<span class=\"grvsc-line\">  const privateKey = (await openpgp.key.readArmored([privateKeyArmored])).keys[0];</span>\n<span class=\"grvsc-line\">  await privateKey.decrypt(passphrase);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  const decrypted = await openpgp.decrypt({</span>\n<span class=\"grvsc-line\">    message: await openpgp.message.readArmored(fs.createReadStream(&quot;encrypted-dataset.txt&quot;)),</span>\n<span class=\"grvsc-line\">    privateKeys: [privateKey],</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  let readStream = decrypted.data;</span>\n<span class=\"grvsc-line\">  let writeStream = fs.createWriteStream(&quot;decrypted-dataset.json&quot;, { flags: &quot;a&quot; });</span>\n<span class=\"grvsc-line\">  readStream.pipe(writeStream);</span>\n<span class=\"grvsc-line\">  readStream.on(&quot;end&quot;, () =&gt; console.log(&quot;done!&quot;));</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Now, <code>decrypted-dataset.json</code> will have the same contents as our original <code>dataset-1mill.json</code> file.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","frontmatter":{"date":"November 10, 2020","updated_date":null,"description":"Starter guide on Pretty Good Privacy(PGP) with Nodejs. PGP, a cryptographic process used to encrypt and decrypt information.","title":"Using PGP Encryption with Nodejs","tags":["Security","NodeJs","Encryption"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.7699115044247788,"src":"/static/17b7404342f677f5ecd47557fd49ab6f/58556/cover.webp","srcSet":"/static/17b7404342f677f5ecd47557fd49ab6f/61e93/cover.webp 200w,\n/static/17b7404342f677f5ecd47557fd49ab6f/1f5c5/cover.webp 400w,\n/static/17b7404342f677f5ecd47557fd49ab6f/58556/cover.webp 800w,\n/static/17b7404342f677f5ecd47557fd49ab6f/54d25/cover.webp 1080w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Andy Yeung","github":null,"avatar":null}}}},{"node":{"excerpt":"Python is a general-purpose programming language and has overtaken Java in popularity according to a recent Stackoverflow survey.  People…","fields":{"slug":"/engineering/python-basics-in-minutes/"},"html":"<p>Python is a general-purpose programming language and has overtaken Java in popularity according to a recent Stackoverflow survey. </p>\n<p>People who have never programmed before are tempted to try due to the simplicity to learn and use it. Well, let's get down to business.</p>\n<h2 id=\"before-we-get-started\" style=\"position:relative;\"><a href=\"#before-we-get-started\" aria-label=\"before we get started permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Before we get started</h2>\n<p>Before we get started, there are a few things you should know about python:</p>\n<ul>\n<li>Python is a high-level programming language, which means it has a strong abstraction from the computer's details (that's why it's so easy and understandable). Because of that, it may be not so efficient as other languages like assembly, C, or C++;</li>\n<li>Python is an interpreted language. Its syntax is read and then executed directly. The interpreter reads each program statement, following the program flow, then decides what to do and does it. That's why you should test all your programs, even if everything seems to be working correctly. If there is an error within a loop, for example, it will only be shown if the loop is executed;</li>\n<li>Python has excellent documentation <a href=\"https://docs.python.org/3/\">that you can access here</a> and an incredible community. Use them.</li>\n</ul>\n<h2 id=\"print-function\" style=\"position:relative;\"><a href=\"#print-function\" aria-label=\"print function permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Print function</h2>\n<p><em>We are assuming that you have already installed python. If you do not, please click <a href=\"https://www.python.org/downloads/\">here</a>.</em></p>\n<p>To write your first Python code, open your text editor and type: </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">print(&quot;Hello world, this is my first python code&quot;)</span></code></pre>\n<p>Save the file as <code>helloworld.py</code> and put it into the python interpreter to be executed.\nYou also can run your code on the command line:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">C:\\Users\\Your Name&gt;python helloworld.py</span></code></pre>\n<p>If everything went well, you should see something like this:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">&gt; Hello world, this is my first python code</span></code></pre>\n<p>You can also use the print function to show integers, variables, lists, etc. Try it!</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">#show the sum of two integers</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number1 = </span><span class=\"mtk7\">5</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number2 = </span><span class=\"mtk7\">7</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(number1+number2)</span></span></code></pre>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">#dividing two decimals</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number1 = </span><span class=\"mtk10\">float</span><span class=\"mtk1\">(</span><span class=\"mtk7\">12.1</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number2 = </span><span class=\"mtk10\">float</span><span class=\"mtk1\">(</span><span class=\"mtk7\">4</span><span class=\"mtk1\">)</span></span></code></pre>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">#concatenating strings</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">name = </span><span class=\"mtk8\">&quot;Python&quot;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">phrase = </span><span class=\"mtk10\">str</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I hate &quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I love &quot;</span><span class=\"mtk1\">, name)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(phrase+name)</span></span></code></pre>\n<h2 id=\"data-types\" style=\"position:relative;\"><a href=\"#data-types\" aria-label=\"data types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Data Types</h2>\n<p>Python has the following data types built-in by default, in these categories:</p>\n<ul>\n<li>Text Type:\t<code>str</code> <em>(string)</em></li>\n<li>Numeric Types:\t<code>int</code> <em>(integer)</em>, <code>float</code> <em>(decimal)</em>, <code>complex</code></li>\n<li>Sequence Types:\t<code>list</code>, <code>tuple</code>, <code>range</code></li>\n<li>Mapping Type:\t<code>dict</code></li>\n<li>Set Types:\t<code>set</code>, <code>frozenset</code></li>\n<li>Boolean Type:\t<code>bool</code></li>\n<li>Binary Types:\t<code>bytes</code>, <code>bytearray</code>, <code>memoryview</code></li>\n</ul>\n<blockquote>\n<p><strong>Note:</strong> Variables in Python are interpreted as integers by default. Is a good practice to declare them as another type <em>explicitly</em> (if they aren't integers). You can see the kind of a variable using the function <code>type()</code>.</p>\n</blockquote>\n<h2 id=\"python-operators\" style=\"position:relative;\"><a href=\"#python-operators\" aria-label=\"python operators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Python Operators</h2>\n<p>Operators are used to performing operations on variables and values.\nThe main groups are:</p>\n<ul>\n<li>Arithmetic operators</li>\n<li>Comparison operators</li>\n<li>Logical operators</li>\n</ul>\n<h3 id=\"arithmetic-operators\" style=\"position:relative;\"><a href=\"#arithmetic-operators\" aria-label=\"arithmetic operators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Arithmetic operators</h3>\n<p><em>Arithmetic operators are used with numeric values to perform common mathematical operations.</em></p>\n<ul>\n<li><strong>Addition</strong>:\t<code>x + y</code></li>\n<li><strong>Subtraction:</strong> <code>x - y</code></li>\n<li><strong>Multiplication:</strong> <code>x * y</code></li>\n<li><strong>Division:</strong> <code>x / y</code></li>\n<li><strong>Modulus:</strong> <code>x % y</code>\t</li>\n<li><strong>Exponentiation:</strong> <code>x ** y</code>\t</li>\n<li><strong>Floor division:</strong> <code>x // y</code></li>\n</ul>\n<h3 id=\"comparison-operators\" style=\"position:relative;\"><a href=\"#comparison-operators\" aria-label=\"comparison operators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Comparison operators</h3>\n<p><em>Comparison operators are used to compare two values.</em></p>\n<ul>\n<li><strong>Equal:</strong> <code>x == y</code></li>\n<li><strong>Not equal:</strong> <code>x != y</code></li>\n<li><strong>Greater than:</strong> <code>x > y</code></li>\n<li><strong>Less than:</strong> <code>x &#x3C; y</code>\t</li>\n<li><strong>Greater than or equal to:</strong> <code>x >= y</code></li>\n<li><strong>Less than or equal to:</strong>\t<code>x &#x3C;= y</code></li>\n</ul>\n<h3 id=\"logical-operators\" style=\"position:relative;\"><a href=\"#logical-operators\" aria-label=\"logical operators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Logical operators</h3>\n<p><em>Logical operators are used to combine conditional statements.</em></p>\n<ul>\n<li><strong>and</strong> -> Returns True if both statements are true\n<code>x &#x3C; 2 and x &#x3C; 4</code></li>\n<li><strong>or</strong> ->\tReturns True if one of the statements is true\n<code>x &#x3C; 10 or x &#x3C; 9</code></li>\n<li><strong>not</strong> -> Reverse the result, returns False if the result is true\n<code>not(x &#x3C; 2 and x &#x3C; 4)</code></li>\n</ul>\n<h2 id=\"if-statement\" style=\"position:relative;\"><a href=\"#if-statement\" aria-label=\"if statement permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>If statement</h2>\n<p>Look to the code below:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">age = </span><span class=\"mtk7\">18</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">if</span><span class=\"mtk1\"> (age&lt;</span><span class=\"mtk7\">21</span><span class=\"mtk1\">):</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;The student is underage!&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">elif</span><span class=\"mtk1\"> (age==</span><span class=\"mtk7\">21</span><span class=\"mtk1\">):</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;The student is 21!&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">else</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;The student isn&#39;t underage!&quot;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>In programming, we often have to choose what to do depending on the situation. It is essential to know how to use conditional arguments like <code>if</code>and <code>else</code>.\nThe code above print a different message according to a condition.</p>\n<p>Try to write a code that asks for two test scores. If the average is less than 7, the user should see \"I'm sorry, you didn't do well on the tests\". If the average is exactly 7, the user should see \"You did it!\". And if it is greater than 7, the user should see \"Congratulations!! You're a great student.\".</p>\n<blockquote>\n<p><strong>Note:</strong> to request a response from the user, you need to use the <code>input()</code> function. For example:</p>\n</blockquote>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">name = </span><span class=\"mtk10\">str</span><span class=\"mtk1\">(</span><span class=\"mtk11\">input</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;What&#39;s your name?&quot;</span><span class=\"mtk1\">))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">age = </span><span class=\"mtk10\">int</span><span class=\"mtk1\">(</span><span class=\"mtk11\">input</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;How old are you? &quot;</span><span class=\"mtk1\">))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I&#39;m </span><span class=\"mtk4\">%s</span><span class=\"mtk8\"> and I&#39;m </span><span class=\"mtk4\">%d</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">% (name, age))</span></span></code></pre>\n<h2 id=\"loops\" style=\"position:relative;\"><a href=\"#loops\" aria-label=\"loops permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Loops</h2>\n<p>Python has two primitive loop commands: <code>while</code> and <code>for</code>.</p>\n<h3 id=\"while-loop\" style=\"position:relative;\"><a href=\"#while-loop\" aria-label=\"while loop permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>While loop</h3>\n<p><em>With the while loop, we can execute a set of statements as long as a condition is true.</em></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">count = </span><span class=\"mtk7\">0</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">while</span><span class=\"mtk1\"> count &lt; </span><span class=\"mtk7\">10</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(count)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    count += </span><span class=\"mtk7\">1</span><span class=\"mtk1\">    </span><span class=\"mtk3\">#this line is the same as    count = count+1</span></span></code></pre>\n<p>The code above will print count as long as count is less than 10.</p>\n<h3 id=\"for-loop\" style=\"position:relative;\"><a href=\"#for-loop\" aria-label=\"for loop permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>For loop</h3>\n<p>A for loop is used for iterating over a sequence. Using it, we can execute a set of statements, once for each item in a list, tuple, set, string, etc. For example:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">#loop through a string</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;banana&quot;</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(x)</span></span></code></pre>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">#loop through a list of fruits</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">fruits = [</span><span class=\"mtk8\">&quot;apple&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk8\">&quot;banana&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk8\">&quot;melon&quot;</span><span class=\"mtk1\">]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> fruits:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I like&quot;</span><span class=\"mtk1\">, x)</span></span></code></pre>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>Did you understand why python became so popular? In a few minutes, you were able to learn the main concepts of this fantastic language.</p>\n<p>Please comment and share this article!</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n</style>","frontmatter":{"date":"November 06, 2020","updated_date":null,"description":"Learn the basics of Python programming lanuage (For Beginners)","title":"Python basics in minutes","tags":["Python"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/e65362be2b3196aeea5b79ea97dab3a6/58556/python.webp","srcSet":"/static/e65362be2b3196aeea5b79ea97dab3a6/61e93/python.webp 200w,\n/static/e65362be2b3196aeea5b79ea97dab3a6/1f5c5/python.webp 400w,\n/static/e65362be2b3196aeea5b79ea97dab3a6/58556/python.webp 800w,\n/static/e65362be2b3196aeea5b79ea97dab3a6/99238/python.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Sara Lins","github":"saranicoly","avatar":null}}}},{"node":{"excerpt":"What is Rest? Representational State Transfer in short-form as REST defines a set of constraints for creating Web Services.\nRest API is the…","fields":{"slug":"/engineering/rest-api-cucumber-blog/"},"html":"<h2 id=\"what-is-rest\" style=\"position:relative;\"><a href=\"#what-is-rest\" aria-label=\"what is rest permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Rest?</h2>\n<p>Representational State Transfer in short-form as <strong>REST</strong> defines a set of constraints for creating Web Services.\nRest API is the most-used web service technology nowadays, and it's an almost meaningless description. A REST API is a way to communicate for two computer systems over HTTP, which is similar to web browsers and servers.</p>\n<h2 id=\"what-is-bdd\" style=\"position:relative;\"><a href=\"#what-is-bdd\" aria-label=\"what is bdd permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is BDD?</h2>\n<p>BDD stands for <strong>Behavior Driven Development</strong> (BDD). Nowadays, many Organizations, to get a better advantage of testing, are taking a step forward.  </p>\n<ul>\n<li>BDD allows us to create test scripts from both the developer’s and the customer’s perspective.</li>\n<li>BDD uses human-readable descriptions of software user requirements as the basis for software tests</li>\n</ul>\n<h2 id=\"what-is-cucumber\" style=\"position:relative;\"><a href=\"#what-is-cucumber\" aria-label=\"what is cucumber permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Cucumber?</h2>\n<p>A cucumber is an approach that supports BDD. It allows you to write tests that anyone can understand, irrespective of their technical knowledge. In BDD, users (business analysts, product owners, developers, etc..). We need to first write scenarios or acceptance tests that describe the system's behavior from the customer's point of view for review and sign-off by the product owners before developers start actual development.</p>\n<h2 id=\"what-are-the-prerequisites-to-test-rest-api-using-cucumber\" style=\"position:relative;\"><a href=\"#what-are-the-prerequisites-to-test-rest-api-using-cucumber\" aria-label=\"what are the prerequisites to test rest api using cucumber permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What are the Prerequisites to Test Rest API using Cucumber?</h2>\n<ul>\n<li>Java</li>\n<li>Editor (Eclipse, IntelliJ, etc..)</li>\n<li>Maven</li>\n</ul>\n<h3 id=\"steps-to-install-java\" style=\"position:relative;\"><a href=\"#steps-to-install-java\" aria-label=\"steps to install java permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Steps to Install Java</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">http://www.oracle.com/technetwork/java/javase/downloads/index.html  </span></code></pre>\n<p>Download JDK from the above link and install it\nSet the Environment Variable on System Properties </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">Right Click on My PC -&gt; Properties -&gt; Advanced System Settings -&gt; Environment Variables -&gt; Create New -&gt; provide path of JDK</span></code></pre>\n<h3 id=\"steps-to-install-eclipse\" style=\"position:relative;\"><a href=\"#steps-to-install-eclipse\" aria-label=\"steps to install eclipse permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Steps to Install Eclipse</h3>\n<ul>\n<li>Make Sure Java is installed on your PC.</li>\n<li>Use the below link to download Eclipse :\n<a href=\"https://eclipse.org/downloads\">Eclipse Download</a></li>\n<li>Install Eclipse on your PC </li>\n</ul>\n<p><strong>Steps to Install Maven</strong></p>\n<ul>\n<li>Use the below link to download Maven :\n<a href=\"https://maven.apache.org/download.cgi\">Maven Download</a></li>\n<li>Set the environment variable.</li>\n</ul>\n<h3 id=\"configuring-cucumber-with-maven\" style=\"position:relative;\"><a href=\"#configuring-cucumber-with-maven\" aria-label=\"configuring cucumber with maven permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configuring Cucumber with Maven</h3>\n<ul>\n<li>\n<p>Create a Maven Project. Use below navigation.</p>\n<p><code>Open Eclipse -> File -> New -> Maven Project</code>\n</p>\n</li>\n<li>\n<p>Provide Group Id and Artifact Id and click on finish. </p>\n<p><strong>Group Id:</strong> This element indicates the organization's unique identifier or group that created the project. The groupId is one of the key identifiers of a project and is typically based on your organization's fully qualified domain name. For example, <code>com.loginradius</code>  is the designated groupId for all Maven plugins.</p>\n<p><strong>Artifact Id:</strong>  it points to the unique base name of the primary artifact generated by this project. The main or primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name.</p>\n</li>\n<li>\n<p>Open pom.xml file to add necessary dependencies </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;io.cucumber&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;cucumber-java&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;6.6.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span>\n<span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;io.cucumber&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;cucumber-testng&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;6.6.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span>\n<span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;io.rest-assured&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;rest-assured&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;4.3.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">\t&lt;scope&gt;test&lt;/scope&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span>\n<span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;org.testng&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;testng&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;7.1.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">\t&lt;scope&gt;test&lt;/scope&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span></code></pre>\n</li>\n</ul>\n<p> Now we need three Important files.</p>\n<ul>\n<li>Feature file</li>\n<li>StepDefination file</li>\n<li>Runner file</li>\n</ul>\n<p> <strong>Feature File:</strong>  It's a entry point to the cucumber. We use Gherkins to write the feature file. This is the file where you will describe your descriptive language(Gherkin uses simple English). A feature file can contains a Scenario or List of Scenario. A sample Feature file is below</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">Feature: Login Functionality</span>\n<span class=\"grvsc-line\">@validLogin</span>\n<span class=\"grvsc-line\">Scenario: User Should Login With Valid Credentials </span>\n<span class=\"grvsc-line\">   Given Post Login API</span>\n<span class=\"grvsc-line\">   When Provide Valid Credential</span>\n<span class=\"grvsc-line\">   Then Status_code equals 200    </span>\n<span class=\"grvsc-line\">   And  response contains IsLogin equals &quot;true&quot;</span>\n<span class=\"grvsc-line\">@invalidLogin    </span>\n<span class=\"grvsc-line\">Scenario Outline: Email and Password Validation in Login API </span>\n<span class=\"grvsc-line\">   Given Post Login API</span>\n<span class=\"grvsc-line\">   When Provide different combinations to &quot;&lt;email&gt;&quot;&quot;&lt;password&gt;&quot;</span>\n<span class=\"grvsc-line\">   Then Status_code equals &lt;statuscode&gt;    </span>\n<span class=\"grvsc-line\">   And  response contains message equals &quot;&lt;message&gt;&quot;</span>\n<span class=\"grvsc-line\">   Examples:</span>\n<span class=\"grvsc-line\">   |email     \t\t|password    | statuscode |  message</span>\n<span class=\"grvsc-line\">   |          \t\t|            |   401      | Required email and password</span>\n<span class=\"grvsc-line\">   | abc\t  \t|            |   401      | Email format is incorrect</span>\n<span class=\"grvsc-line\">   | abc@mail7.io  \t|\t     |   401      | Required password</span>\n<span class=\"grvsc-line\">   | abc@mail7.io   \t| password   |   401      | Email and Password combination Incorrect</span></code></pre>\n<p> Save the above code as login.feature </p>\n<ul>\n<li><strong>Feature:</strong> It indicates the name of the feature under the test.</li>\n<li><strong>Description:</strong> It indicates a meaningful description of the feature (Optional).</li>\n<li><strong>scenario:</strong> scenario indicates the steps and expected outcomes for a particular test case.</li>\n<li><strong>Scenario Outline:</strong> Single scenario can be executed for multiple data sets using scenario outlines. The data is provided by a tabular structure separated by (I I).</li>\n<li><strong>Given:</strong> Prerequisite before the test steps get executed.</li>\n<li><strong>When:</strong> Specific condition which should match to execute the next step.</li>\n<li><strong>Then:</strong> What should happen if the condition mentioned in WHEN is satisfied.</li>\n<li><strong>Examples:</strong> Its a tabular format input data to pass to scenario outline.</li>\n<li><strong>&#x3C;>:</strong> anything if you write between is variable. </li>\n</ul>\n<p><strong>StepDefinition:</strong>\nNow you have your feature file ready with test scenarios defined. However, our job is not done yet. Cucumber doesn't know when should execute which part of code. So StepDefinition acts as an intermediate to your runner and feature file. It stores the mapping between each step of the scenario in the Feature file. So when you run the scenario, it will scan the stepDefination file to check matched glue.</p>\n<p><strong>How to write step definition:</strong>\nWe have a chrome extension(Tidy Gherkin) to convert your feature into a step definition.<br>\nCopy your scenario from the feature file and paste it in Tidy Gherkin and click on Java Steps; copy the Java Steps.\nCreate a new file name a StepDefinition.java and paste the Java Steps</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"java\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">package</span><span class=\"mtk1\"> com.loginradius.login</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk14\">import</span><span class=\"mtk1\"> cucumber.api.java.en.</span><span class=\"mtk14\">G</span><span class=\"mtk1\">iven;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.java.en.When;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.java.en.Then;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.java.en.And;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.junit.Cucumber;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> org.junit.runner.RunWith;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> </span><span class=\"mtk4\">static</span><span class=\"mtk1\"> io.restassured.RestAssured.given;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> </span><span class=\"mtk4\">static</span><span class=\"mtk1\"> org.testng.Assert.assertTrue;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.http.ContentType;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.response.Response;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.specification.RequestSpecification;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.RestAssured;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk4\">class</span><span class=\"mtk1\"> </span><span class=\"mtk10\">StepDefinition</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span><span class=\"mtk4\">private</span><span class=\"mtk1\">  </span><span class=\"mtk4\">static</span><span class=\"mtk1\">  </span><span class=\"mtk4\">final</span><span class=\"mtk1\">  </span><span class=\"mtk10\">String</span><span class=\"mtk1\">  </span><span class=\"mtk12\">BASE_URL</span><span class=\"mtk1\">  =  </span><span class=\"mtk8\">&quot;https://www.loginradius.com&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> </span><span class=\"mtk12\">email</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&quot;abcxyz@mail7.io;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tString password = &quot;</span><span class=\"mtk1\">password</span><span class=\"mtk8\">&quot;;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tRequestSpecification request;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tprivate  static  Response response;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tprivate  static  String  jsonString;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    @Given(&quot;</span><span class=\"mtk10\">Post</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Login</span><span class=\"mtk1\"> API</span><span class=\"mtk8\">&quot;)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    public void post_login_api() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\t    RestAssured.baseURI  =  BASE_URL;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\t\trequest  =  RestAssured.given();</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\t\trequest.header(&quot;</span><span class=\"mtk1\">Content-Type</span><span class=\"mtk8\">&quot;,  &quot;</span><span class=\"mtk1\">application/json</span><span class=\"mtk8\">&quot;);    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">   @When(&quot;</span><span class=\"mtk10\">Provide</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Valid</span><span class=\"mtk1\"> Credential</span><span class=\"mtk8\">&quot;)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    public void provide_valid_credential() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">      response  =  request.body(&quot;</span><span class=\"mtk1\">{ \\</span><span class=\"mtk8\">&quot;userName</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">  +  email  +  </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">, </span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">password</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">  +  password  +  </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t\t\t\t\t  .</span><span class=\"mtk11\">post</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;/user/login&quot;</span><span class=\"mtk1\">);\t</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   @</span><span class=\"mtk10\">Then</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;Status_code equals {int}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">statuscode_equals_</span><span class=\"mtk1\">(</span><span class=\"mtk10\">int</span><span class=\"mtk1\"> agr) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    </span><span class=\"mtk12\">Assert</span><span class=\"mtk1\">.</span><span class=\"mtk11\">assertEquals</span><span class=\"mtk1\">(arg, </span><span class=\"mtk12\">response</span><span class=\"mtk1\">.</span><span class=\"mtk11\">getStatusCode</span><span class=\"mtk1\">());</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t@</span><span class=\"mtk10\">And</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;response contains IsPosted equals {string}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">response_contains_IsPosted_equals_</span><span class=\"mtk1\">(</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> message) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    </span><span class=\"mtk12\">Assert</span><span class=\"mtk1\">.</span><span class=\"mtk11\">assertEquals</span><span class=\"mtk1\">(message, </span><span class=\"mtk11\">getJsonPath</span><span class=\"mtk1\">(response, </span><span class=\"mtk8\">&quot;IsPosted&quot;</span><span class=\"mtk1\">));</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }\t</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   @</span><span class=\"mtk10\">And</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;response contains message equals {string}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">response_contains_equals_</span><span class=\"mtk1\">(</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> message) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    </span><span class=\"mtk12\">Assert</span><span class=\"mtk1\">.</span><span class=\"mtk11\">assertEquals</span><span class=\"mtk1\">(message, </span><span class=\"mtk11\">getJsonPath</span><span class=\"mtk1\">(response, </span><span class=\"mtk8\">&quot;message&quot;</span><span class=\"mtk1\">));</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t@</span><span class=\"mtk10\">When</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;Provide different combinations to {string}, {string}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">provide_different_combinations_to_somethingsomething</span><span class=\"mtk1\">(</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> email, </span><span class=\"mtk10\">String</span><span class=\"mtk1\"> password){</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    response = </span><span class=\"mtk12\">request</span><span class=\"mtk1\">.</span><span class=\"mtk11\">body</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;{ </span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">userName</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\"> + email + </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">, </span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">password</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\"> + password + </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">}&quot;</span><span class=\"mtk1\">) .</span><span class=\"mtk11\">post</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;/user/login&quot;</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">String</span><span class=\"mtk1\"> </span><span class=\"mtk11\">getJsonPath</span><span class=\"mtk1\">(</span><span class=\"mtk10\">Response</span><span class=\"mtk1\"> response, </span><span class=\"mtk10\">String</span><span class=\"mtk1\"> key) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> </span><span class=\"mtk12\">resp</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">response</span><span class=\"mtk1\">.</span><span class=\"mtk11\">asString</span><span class=\"mtk1\">();</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t</span><span class=\"mtk10\">JsonPath</span><span class=\"mtk1\"> </span><span class=\"mtk12\">js</span><span class=\"mtk1\"> = </span><span class=\"mtk15\">new</span><span class=\"mtk1\"> </span><span class=\"mtk11\">JsonPath</span><span class=\"mtk1\">(resp);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t</span><span class=\"mtk15\">return</span><span class=\"mtk1\"> </span><span class=\"mtk12\">js</span><span class=\"mtk1\">.</span><span class=\"mtk11\">get</span><span class=\"mtk1\">(key).</span><span class=\"mtk11\">toString</span><span class=\"mtk1\">();</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span></code></pre>\n<p>Now we have Our Feature file and StepDefinition Ready, we need a runner file to run our Test Scenario's</p>\n<p><strong>Runner File:</strong>\nA runner will help us to run the feature file and acts as an interlink between the feature file and StepDefinition Class\nBelow is the code which will help you to run the tests</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"java\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">package</span><span class=\"mtk1\"> runner;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.cucumber.testng.CucumberOptions;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">@</span><span class=\"mtk10\">CucumberOptions</span><span class=\"mtk1\">(</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\tfeatures= {</span><span class=\"mtk8\">&quot;feature_files/login.feature&quot;</span><span class=\"mtk1\">},</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        glue= {</span><span class=\"mtk8\">&quot;step_definations/StepDefinitation.java&quot;</span><span class=\"mtk1\">},</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        tags= </span><span class=\"mtk8\">&quot;@validLogin&quot;</span><span class=\"mtk1\">,    </span><span class=\"mtk3\">// based on tags scenarios will run</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        monochrome=</span><span class=\"mtk4\">true</span><span class=\"mtk1\">, dryRun=</span><span class=\"mtk4\">false</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t)\t</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">public</span><span class=\"mtk1\">  </span><span class=\"mtk4\">class</span><span class=\"mtk1\">  </span><span class=\"mtk10\">TestRunner</span><span class=\"mtk1\">  {</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span></code></pre>\n<p>Now We have Feature, StepDefinition, and runner files ready, We can run the runner file to see the results.</p>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>Cucumber is very useful in understanding the overall testing process without having coding knowledge. Since it uses simple English to write the feature file and makes developer, QA and other stakeholders on same page before starting the actual development.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk14 { color: #F44747; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk6 { color: #D7BA7D; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n</style>","frontmatter":{"date":"November 05, 2020","updated_date":null,"description":"This article is about basic overview of how to automate Rest API using Cucumber and JAVA.","title":"Automating Rest API's using Cucumber and Java","tags":["Automation","Cucumber","Rest API","Java"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/1775ed5790237a2d1ac5fbda108bc357/58556/cucumber_rest_assured.webp","srcSet":"/static/1775ed5790237a2d1ac5fbda108bc357/61e93/cucumber_rest_assured.webp 200w,\n/static/1775ed5790237a2d1ac5fbda108bc357/1f5c5/cucumber_rest_assured.webp 400w,\n/static/1775ed5790237a2d1ac5fbda108bc357/58556/cucumber_rest_assured.webp 800w,\n/static/1775ed5790237a2d1ac5fbda108bc357/99238/cucumber_rest_assured.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Surendranath Reddy Birudala","github":"reddysuren","avatar":null}}}}]},"markdownRemark":{"excerpt":"Introduction Ever wondered how apps like Spotify, Netflix, or Slack manage seamless login experiences across devices? Many of them use JWT…","fields":{"slug":"/engineering/how-to-integrate-jwt/"},"html":"<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>Ever wondered how apps like Spotify, Netflix, or Slack manage seamless login experiences across devices? Many of them use JWT, or JSON Web Tokens, a compact, stateless method for securely transmitting user identity and session data across services.</p>\n<p>With JWT token authentication, identity information is embedded in a signed token, allowing you to maintain user sessions without server-side storage. This approach is highly scalable and ideal for modern architectures like SPAs, mobile apps, and microservices.</p>\n<p>In this blog, we’ll walk you through what is JWT, why use it, and how to implement JWT authentication using LoginRadius. </p>\n<p>You’ll learn what JWT is, why it’s effective, and how it works in real-world applications. We'll cover both integration methods (IDX and Direct API), generating your signing key, managing sessions, storing the JWT token securely, and applying best practices throughout.</p>\n<p>Whether you're a developer, product manager, or IAM architect, this guide offers a complete foundation for implementing JWT token authentication into your application stack.</p>\n<h2 id=\"what-is-jwt\" style=\"position:relative;\"><a href=\"#what-is-jwt\" aria-label=\"what is jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is JWT?</h2>\n<p><a href=\"https://www.loginradius.com/blog/engineering/jwt/\">JSON Web Token (JWT)</a> is an open standard (RFC 7519) used to transmit information securely between parties as a JSON object. It’s compact, self-contained, and digitally signed, making it a reliable format for authentication and authorization across modern applications.</p>\n<p>A JWT consists of three parts:</p>\n<ol>\n<li><strong>Header –</strong> Contains metadata like the type of token and signing algorithm (e.g., HS256).</li>\n<li><strong>Payload –</strong> Stores the actual data or “claims,” such as user ID, roles, and token expiry.</li>\n<li><strong>Signature –</strong> A cryptographic hash that ensures the token hasn’t been tampered with.</li>\n</ol>\n<p><em>Example of a token structure:</em></p>\n<p>&#x3C;base64Header>.&#x3C;base64Payload>.&#x3C;signature></p>\n<h2 id=\"why-use-jwt\" style=\"position:relative;\"><a href=\"#why-use-jwt\" aria-label=\"why use jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Use JWT?</h2>\n<ul>\n<li><strong>Stateless Authentication</strong>: No server-side session storage is needed — the token holds all necessary user info. </li>\n<li><strong>Portable</strong>: Works seamlessly across domains, services, and APIs. </li>\n<li><strong>Scalable</strong>: Ideal for microservices, SPAs, mobile apps, and serverless functions. </li>\n<li><strong>Interoperable</strong>: JWTs are supported across many languages and frameworks.</li>\n</ul>\n<h2 id=\"how-jwt-works\" style=\"position:relative;\"><a href=\"#how-jwt-works\" aria-label=\"how jwt works permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How JWT Works?</h2>\n<p><img src=\"/f29edbf2978577390c7ffa02e9bc4dda/lr-JWT-authentication.webp\" alt=\"Flowchart illustrating LoginRadius JWT authentication via Identity Provider (IDP), showing user redirection from login icon to login page, authentication with IDP, JWT token validation, and subsequent redirection to the customer&#x27;s website or error page based on validation results.\"></p>\n<ol>\n<li>A user logs in with credentials. </li>\n<li>Your app (or identity provider like LoginRadius) issues a signed JWT. </li>\n<li>The client stores the token and sends it with each request (usually in the Authorization header). </li>\n<li>The server validates the token’s signature and claims. </li>\n<li>If valid, access is granted — without any session stored on the backend.</li>\n</ol>\n<p>JWT simplifies identity verification, especially when you're building apps that talk to APIs or need to scale without centralized session storage.</p>\n<h2 id=\"jwt-authentication-with-loginradius-overview\" style=\"position:relative;\"><a href=\"#jwt-authentication-with-loginradius-overview\" aria-label=\"jwt authentication with loginradius overview permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JWT Authentication with LoginRadius: Overview</h2>\n<p>LoginRadius provides robust support for JWT (JSON Web Token) authentication, which allows for flexible and secure access control across different digital platforms. Whether you're building a fully custom identity flow or using a pre-built interface, the platform supports various integration approaches depending on your architecture.</p>\n<p>If you're looking to understand how to implement JWT token authentication effectively, LoginRadius offers two primary implementation models that cater to different levels of customization and control:</p>\n<h3 id=\"1-idx-implementation--jwt-through-a-hosted-login-page\" style=\"position:relative;\"><a href=\"#1-idx-implementation--jwt-through-a-hosted-login-page\" aria-label=\"1 idx implementation  jwt through a hosted login page permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. IDX Implementation – JWT through a Hosted Login Page</h3>\n<p>The IDX-hosted login approach enables secure, standards-compliant, JWT-based authentication without requiring you to build a custom login interface. This is a strategic option for fast, compliant, and user-friendly deployments.</p>\n<ul>\n<li>The Identity Experience Framework (IDX) comes with a fully custom branded hosted login page.</li>\n<li>Once the user logs in and gets enrolled, the user’s JWTs are automatically generated and issued. These tokens can be utilized for managing user sessions and accessing the APIs.</li>\n<li>This approach simplifies deployment without compromising on user experience and security standards.</li>\n</ul>\n<h3 id=\"configuration-steps\" style=\"position:relative;\"><a href=\"#configuration-steps\" aria-label=\"configuration steps permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Configuration Steps:</strong></h3>\n<ol>\n<li>Enable JWT Login</li>\n<li>Go to <a href=\"https://console.loginradius.com/authentication/authentication-configuration\">authentication configuration settings</a> and enable JWT Login in the Admin Console.</li>\n</ol>\n<p><img src=\"/9fb19dd9c88c7916aeebd03ab6e661b7/lr-admin-console.webp\" alt=\"Screenshot of LoginRadius Admin Console showing JWT Custom IDP configuration interface with options for provider name, algorithm (HS256), key entry, clock skew, and expiration time settings.\"></p>\n<ol start=\"2\">\n<li>Specify your signing algorithm and expiry policy, and define your JWT Secret Key.</li>\n<li>Input a secure JWT signing key.</li>\n<li>Specify token expiry duration (e.g., 15–60 minutes)</li>\n<li>Select the desired algorithm —HS256 for symmetric signing (same key signs and verifies)</li>\n<li>RS256 for asymmetric signing, where LoginRadius securely stores the private key used to sign the JWT.</li>\n<li>Your app or backend service uses the public key to validate the token signature.</li>\n<li>LoginRadius provides a JWKS (JSON Web Key Set) endpoint to dynamically fetch and rotate public keys, ensuring trust without key exposure.</li>\n<li>Update IDX Template for Callback</li>\n<li>Modify your IDX login page template to retrieve the JWT post-login. You can access the token via redirect URL parameters or secure JavaScript callbacks.</li>\n</ol>\n<h3 id=\"example-response\" style=\"position:relative;\"><a href=\"#example-response\" aria-label=\"example response permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example Response:</h3>\n<p>{</p>\n<p>  \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR...\",</p>\n<p>  \"expires_in\": 1800</p>\n<p>}</p>\n<p>This integration approach works best for all teams that want effective identity workflows without the complexity of building proprietary login screens, something that is crucial for customer portals, onboarding of mobile applications, and even managing access for business partners.</p>\n<h3 id=\"2-direct-api-implementation--self-managed-login\" style=\"position:relative;\"><a href=\"#2-direct-api-implementation--self-managed-login\" aria-label=\"2 direct api implementation  self managed login permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. Direct API Implementation – Self Managed Login</h3>\n<p>If you’re building a custom login UI or working in a headless environment, LoginRadius lets you generate and handle JWTs directly through its <a href=\"https://www.loginradius.com/docs/api/v2/customer-identity-api/\">Authentication APIs</a>. Here’s how you can programmatically perform token authentication using the classic method:</p>\n<ul>\n<li>For custom front-end applications, LR offers an API to authenticate users and issue JWT tokens.</li>\n<li>In response to the login request, the developers are provided with signed tokens that can be validated on the client’s side or by downstream services.</li>\n<li>This method is best fit for enterprise applications that have complex custom workflows or are designed to be embedded into other applications.</li>\n</ul>\n<h3 id=\"configuration-steps-1\" style=\"position:relative;\"><a href=\"#configuration-steps-1\" aria-label=\"configuration steps 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Configuration Steps:</strong></h3>\n<h4 id=\"step-1-authenticate-via-api\" style=\"position:relative;\"><a href=\"#step-1-authenticate-via-api\" aria-label=\"step 1 authenticate via api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 1: Authenticate via API:</h4>\n<ul>\n<li>\n<p>Send a POST login request to the LR Authentication URL: </p>\n<p>POST /identity/v2/auth/login</p>\n</li>\n</ul>\n<p>Include the user’s credentials (email + password) in the request body.</p>\n<h4 id=\"step-2-get-jwt-in-response\" style=\"position:relative;\"><a href=\"#step-2-get-jwt-in-response\" aria-label=\"step 2 get jwt in response permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 2: Get JWT in Response</h4>\n<ul>\n<li>If the user credentials are authentic, then the JWT token will be available in response.</li>\n</ul>\n<p>{</p>\n<p> \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\",</p>\n<p> \"expires_in\": 3600</p>\n<p>}</p>\n<h4 id=\"step-3-jwt-decoding-and-validation\" style=\"position:relative;\"><a href=\"#step-3-jwt-decoding-and-validation\" aria-label=\"step 3 jwt decoding and validation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 3: JWT Decoding and Validation</h4>\n<ul>\n<li>Use any JWT library (e.g., jsonwebtoken for Node.js or pyjwt for Python) to decode the token.</li>\n<li>Validate the signature using your configured secret key.</li>\n<li>Confirm claims like exp, iat, aud, and iss.</li>\n</ul>\n<h4 id=\"step-4-set-custom-claims-optional\" style=\"position:relative;\"><a href=\"#step-4-set-custom-claims-optional\" aria-label=\"step 4 set custom claims optional permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 4: Set Custom Claims (Optional)</h4>\n<p>With LoginRadius, it is possible to customize the payload to include user roles and/or any additional metadata. You can set custom JWT claims on the Admin Console.</p>\n<p>With this method, you have complete customization over login flows while using LoginRadius to issue signed JWTs for user session management.</p>\n<p><strong>NOTE-</strong> With either method, LoginRadius ensures that JWTs are securely signed, optionally short-lived, and compatible with standard token validation libraries, making integration seamless for everyone.</p>\n<p>To get started with JWT implementation, you can<a href=\"https://www.loginradius.com/docs/single-sign-on/federated-sso/jwt-login/jwt-implementation-guide/\"> read our complete developer documentation</a>. </p>\n<h2 id=\"hosted-login-vs-direct-api\" style=\"position:relative;\"><a href=\"#hosted-login-vs-direct-api\" aria-label=\"hosted login vs direct api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Hosted Login vs Direct API</h2>\n<p><img src=\"/15ec02ac98d24a9f1f28e5d0f06b9174/IDX-vs-Direct-API-JWT.webp\" alt=\"Illustration showing IDX vs Direct API JWT flow diagram comparing LoginRadius JWT authentication methods via Hosted Login Page (IDX) and Custom Login UI using Direct API, illustrating user login, JWT issuance, and token return process.\"></p>\n<h2 id=\"what-is-session-management-and-how-it-works-with-jwt\" style=\"position:relative;\"><a href=\"#what-is-session-management-and-how-it-works-with-jwt\" aria-label=\"what is session management and how it works with jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Session Management and How It Works with JWT</h2>\n<p><a href=\"https://www.loginradius.com/blog/identity/user-session-management/\">Session management </a>is how your app keeps track of a user after they log in so they don’t have to prove who they are with every request.</p>\n<p>In traditional apps, sessions are stored on the server using session IDs. Every time a request comes in, the server checks that session ID to verify the user.</p>\n<p>In modern apps, especially SPAs and APIs, JWTs are used to manage sessions without needing server-side storage; this is called stateless session management. The token itself carries the user’s identity, roles, and expiration details. As long as the token is valid, the user stays logged in.</p>\n<p>Good session management ensures:</p>\n<ul>\n<li>Security against session hijacking</li>\n<li>Fast user validation without hitting a database</li>\n<li>Smooth experiences with token refresh strategies</li>\n</ul>\n<h2 id=\"how-loginradius-handles-session-management-with-jwt\" style=\"position:relative;\"><a href=\"#how-loginradius-handles-session-management-with-jwt\" aria-label=\"how loginradius handles session management with jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How LoginRadius Handles Session Management with JWT:</h2>\n<ol>\n<li>\n<p>User Logs In </p>\n<ul>\n<li>LoginRadius returns an access token (JWT) and, optionally, a refresh token.</li>\n</ul>\n</li>\n<li>\n<p>Client Stores the Token </p>\n<ul>\n<li>Access tokens are stored in memory, sessionStorage, or secure cookies. </li>\n<li>They’re sent on every request via the Authorization: Bearer header. </li>\n</ul>\n</li>\n<li>\n<p>Access Token Expiry </p>\n<ul>\n<li>These tokens are short-lived by design (e.g., 15–30 minutes). </li>\n<li>Once expired, the client can use the refresh token to request a new access token. </li>\n</ul>\n</li>\n<li>\n<p>Token Renewal </p>\n<ul>\n<li>LoginRadius validates the refresh token and issues a new JWT, i.e., no user re-authentication is needed. </li>\n<li>Refresh tokens can be revoked at any time.</li>\n</ul>\n</li>\n<li>Logout and Token Revocation Strategy</li>\n</ol>\n<p>When the user logs out, both the access token and refresh token should be cleared from client storage.</p>\n<ul>\n<li>The refresh token can be explicitly revoked via the LoginRadius API, terminating the ability to renew sessions. </li>\n<li>\n<p>However, access tokens are stateless and cannot be revoked mid-lifecycle unless: </p>\n<ul>\n<li>You maintain a blacklist of token IDs (jti claims) and check them on each request. </li>\n<li>You use short-lived access tokens to limit exposure naturally. </li>\n<li>Or, you rotate your JWT signing key, invalidating all previously issued tokens. </li>\n</ul>\n</li>\n</ul>\n<p>Combining these strategies gives you greater control over token misuse and enables a robust, enterprise-grade logout flow. </p>\n<p><a href=\"https://www.loginradius.com/resource/whitepaper/secure-api-using-oauth2\"><img src=\"/e55ae4bbc8ce62e13f03e46e29ebe7cc/api-economy.webp\" alt=\"illustration showing LoginRadius free downloadable resource named API economy is transforming digitization: how to secure it using oauth 2.0.\"></a></p>\n<h2 id=\"how-to-store-jwt-tokens\" style=\"position:relative;\"><a href=\"#how-to-store-jwt-tokens\" aria-label=\"how to store jwt tokens permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to Store JWT Tokens?</h2>\n<p>When you implement JWT-based authentication, the client (browser or mobile app) needs a way to store the access token and, optionally, the refresh token after they are issued by the authentication server. This stored token is then attached to every subsequent request to prove the user's identity.</p>\n<p>Choosing where to store the JWT is a crucial security decision. The most common storage options are:</p>\n<ul>\n<li>localStorage</li>\n<li>sessionStorage</li>\n<li>HTTP-only cookies</li>\n</ul>\n<p>Each option has trade-offs between security, accessibility, and persistence, and the right choice depends on your application's architecture and threat model.</p>\n<h4 id=\"recommended-storage-strategy\" style=\"position:relative;\"><a href=\"#recommended-storage-strategy\" aria-label=\"recommended storage strategy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Recommended Storage Strategy</h4>\n<ul>\n<li>\n<p>Access Tokens </p>\n<ul>\n<li>For SPAs: store in memory or sessionStorage for short-term access </li>\n<li>If stored in the browser, protect against XSS </li>\n</ul>\n</li>\n<li>\n<p>Refresh Tokens</p>\n<ul>\n<li>Always store the JWT refresh token in HTTP-only secure cookies to prevent JavaScript access. This adds a critical layer of protection against XSS attacks.</li>\n<li>Combine with SameSite=Strict or SameSite=Lax attributes to mitigate CSRF risks and ensure the JWT refresh token is only sent in intended contexts.</li>\n</ul>\n</li>\n</ul>\n<h2 id=\"best-practices-for-storing-jwts\" style=\"position:relative;\"><a href=\"#best-practices-for-storing-jwts\" aria-label=\"best practices for storing jwts permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Best Practices for Storing JWTs</h2>\n<ol>\n<li>Never store sensitive tokens (like refresh tokens) in localStorage or sessionStorage.</li>\n<li>Use Secure and HttpOnly flags with cookies to prevent JavaScript access and ensure transmission only over HTTPS.</li>\n<li>Set the SameSite=Strict or Lax attribute on cookies to protect against CSRF.</li>\n<li>Use short-lived access tokens and rotate refresh tokens regularly.</li>\n<li>Implement CSP (Content Security Policy) to reduce XSS risk.</li>\n<li>Avoid storing any tokens in frontend code (e.g., hardcoded in JS files).</li>\n</ol>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>JWT authentication with LoginRadius offers a modern, stateless approach to managing sessions across distributed systems. The IDX integration is ideal for rapid deployment, while the Direct API model is best for organizations needing deep customization and integration flexibility.</p>\n<p>With robust token signing, refresh capabilities, and centralized control, LoginRadius provides a future-ready foundation for secure, scalable identity architecture. <a href=\"https://www.loginradius.com/contact-us?utm_source=blog&#x26;utm_medium=web&#x26;utm_campaign=how-to-integrate-jwt\">Contact us</a> to know more about JWT authentication and implementation guide. </p>\n<h2 id=\"faqs\" style=\"position:relative;\"><a href=\"#faqs\" aria-label=\"faqs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>FAQs</h2>\n<h3 id=\"1-what-is-jwt-authentication-used-for\" style=\"position:relative;\"><a href=\"#1-what-is-jwt-authentication-used-for\" aria-label=\"1 what is jwt authentication used for permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. What is JWT authentication used for?</h3>\n<p><strong>A:</strong> JWT authentication securely verifies user identities, enabling stateless session management across web, mobile apps, and microservices without server-side session storage.</p>\n<h3 id=\"2-how-does-loginradius-simplify-jwt-integration\" style=\"position:relative;\"><a href=\"#2-how-does-loginradius-simplify-jwt-integration\" aria-label=\"2 how does loginradius simplify jwt integration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. How does LoginRadius simplify JWT integration?</h3>\n<p><strong>A:</strong> LoginRadius simplifies JWT integration by offering hosted <a href=\"https://www.loginradius.com/docs/single-sign-on/federated-sso/jwt-login/jwt-implementation-guide/\">IDX login pages </a>and direct API-based authentication methods, enabling rapid deployment and deep customization.</p>\n<h3 id=\"3-is-jwt-authentication-secure\" style=\"position:relative;\"><a href=\"#3-is-jwt-authentication-secure\" aria-label=\"3 is jwt authentication secure permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. Is JWT authentication secure?</h3>\n<p><strong>A:</strong> Yes, JWT authentication is secure when implemented with best practices like short-lived tokens, secure storage methods, signature validation, and refresh token rotation.</p>\n<h3 id=\"4-can-jwt-tokens-be-revoked-with-loginradius\" style=\"position:relative;\"><a href=\"#4-can-jwt-tokens-be-revoked-with-loginradius\" aria-label=\"4 can jwt tokens be revoked with loginradius permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. Can JWT tokens be revoked with LoginRadius?</h3>\n<p><strong>A:</strong> Yes, LoginRadius allows<a href=\"https://www.loginradius.com/docs/api/v2/customer-identity-api/refresh-token/revoke-refresh-token/?q=revoke+jwt\"> revocation of JWT</a> refresh tokens explicitly, and supports strategies like short-lived tokens and key rotation to manage token lifecycles securely.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"April 15, 2025","updated_date":null,"description":"Discover JWT (JSON Web Token) authentication, its advantages, and how to integrate it seamlessly using LoginRadius' hosted IDX and Direct API methods for secure, scalable identity management.","title":"JWT Authentication with LoginRadius: Quick Integration Guide","tags":["JWT","JSON Web Token","Authentication","Authorization"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":0.7782101167315175,"src":"/static/4cedb7829f98208cbc6d5a9aea4e983d/58556/how-to-integrate-jwt.webp","srcSet":"/static/4cedb7829f98208cbc6d5a9aea4e983d/61e93/how-to-integrate-jwt.webp 200w,\n/static/4cedb7829f98208cbc6d5a9aea4e983d/1f5c5/how-to-integrate-jwt.webp 400w,\n/static/4cedb7829f98208cbc6d5a9aea4e983d/58556/how-to-integrate-jwt.webp 800w,\n/static/4cedb7829f98208cbc6d5a9aea4e983d/1cc9f/how-to-integrate-jwt.webp 896w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Kundan Singh","github":null,"avatar":null}}}},"pageContext":{"limit":6,"skip":114,"currentPage":20,"type":"//engineering//","numPages":53,"pinned":"5c425581-f474-5ae9-abe7-cf5342db2aaa"}},"staticQueryHashes":["1171199041","1384082988","2100481360","23180105","528864852"]}