
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Easily add client-side password-protection to your Single Page Applications and HTML files.
Easily add client-side password-protection to your Single Page Applications and HTML files.
Inspired by MaxLaumeister/PageCrypt, but rewritten to use native Web Crypto API and greatly improve UX + security. Thanks for sharing an excellent starting point to create this tool!
There are 3 different ways to use pagecrypt:
Encrypt a single HTML-file with one command:
npx pagecrypt <src> <dest> [password] [options]
Encrypt using a generate password with given length:
npx pagecrypt <src> <dest> -g <length>
Description
Encrypt the <src> HTML file with [password] and save the result in the <dest> HTML file.
Usage
$ pagecrypt <src> <dest> [password] [options]
Options
-g, --generate-password Generate a random password with given length. Must be a number if used.
-v, --version Displays current version
-h, --help Displays this message
Examples
$ pagecrypt index.html encrypted.html password
$ pagecrypt index.html encrypted.html --generate-password 64
$ pagecrypt index.html encrypted.html -g 64
pagecrypt in your build processThis allows automated encrypted builds for single page applications
npm i -D pagecrypt
package.json:
{
"devDependencies": {
"pagecrypt": "^3.0.0"
},
"scripts": {
"build": "...",
"postbuild": "pagecrypt index.html encrypted.html password"
}
}
You can also use pagecrypt in your Node.js scripts:
encrypt(inputFile: string, outputFile: string, password: string): Promise<void>import { encrypt } from 'pagecrypt'
// Encrypt a HTML file and write to the filesystem
await encrypt('index.html', 'encrypted.html', 'password')
encryptHTML(inputHTML: string, password: string): Promise<string>import { encryptHTML } from 'pagecrypt'
// Encrypt a HTML string and return an encrypted HTML string.
// Write it to a file or send as an HTTPS response.
const encryptedHTML = await encryptHTML(
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
Secret
</body>
</html>
`,
'password',
)
generatePassword(length: number): stringimport { generatePassword, encrypt, encryptHTML } from 'pagecrypt'
// Generate a random password without any external dependencies
const pass = generatePassword(64)
// Works with both JS API:s
await encrypt('index.html', 'encrypted.html', pass)
const encryptedHTML = await encryptHTML('html string', pass)
The project consists of four parts:
/web - Web frontend for public webpage (decrypt-template.html). Built using Vite & Tailwind CSS./index.js - pagecrypt main library./cli.js - pagecrypt CLI./test - testing setupnpm install in project root.mkcert to generate local certificates to enable HTTPS for the development server. For example mkcert localhost 192.168.1.32 to generate a two files ending with *.pem.vite.config.js to load the generated *.pem files in the https section.npm run serve, also update to the correct *.pem filenames in the npm script.npm test will run basic tests for JS API and CLI. Verify test results by opening the test/out-*.html files in your browser.
Welcome to submit your pull requests!
FAQs
Easily add client-side password-protection to your Single Page Applications, static websites and HTML files.
The npm package pagecrypt receives a total of 2,572 weekly downloads. As such, pagecrypt popularity was classified as popular.
We found that pagecrypt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.