Welcome folks today in this blog post we will be looking how can be password protect a static html page in browser using staticrypt.js library in node.js and javascript. All the full source code of the application is shown below.
Get Started
In order to get started you need to install the below node.js dependency using the npm
command as shown below
npm i staticrypt
And after that you can add the password to any html
page using the below command
staticrypt index.html password
If you wanna do it practically the command gif is shown below
As you can see in the above gif it created the encrypted
version of the index.html
page and now if I open that page inside the browser I will see a password prompt where I need to enter the password which I set earlier i.e. johnwilliamson
Online Tool to Generate Password Protected HTML Page
You can even go to this tool here where you can copy paste the raw
html that you need to password protect inside the textarea
and also you need to provide the password as well and then it will generate the file
for you. Just download the encrypted html file and you will see the same password protected popup dialog as shown below
https://robinmoisson.github.io/staticrypt/