All Projects → Greenheart → pagecrypt

Greenheart / pagecrypt

Licence: AGPL-3.0 license
Password Protected Single Page Applications and HTML files

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
typescript
32286 projects
CSS
56736 projects

Projects that are alternatives of or similar to pagecrypt

SafePad
SafePad : Encrypted Text Editor. This text editor uses very strong encryption to let you protect your secrets. Great for storing passwords, credit card details or any else that you want to keep safe.
Stars: ✭ 32 (-74.19%)
Mutual labels:  aes-encryption, encryption-tool, cryptography-tools
MGObfuscator
An easy encryptor / decryptor for iOS
Stars: ✭ 17 (-86.29%)
Mutual labels:  pbkdf2, aes-encryption
CryptoKnight
CryptoKnight is a general purpose cryptography desktop app
Stars: ✭ 18 (-85.48%)
Mutual labels:  password, aes-encryption
libVES.c
VESvault End-to-End Encryption API: Encrypt Everything Without Fear of Losing the Key
Stars: ✭ 28 (-77.42%)
Mutual labels:  aes-encryption, encryption-tool
password-dart
A set of high-level APIs over PointyCastle and CryptoUtils to hash and verify passwords securely.
Stars: ✭ 40 (-67.74%)
Mutual labels:  password, pbkdf2
CodeEditText
验证码,密码输入框。支持密码、明文展示。背景支持边框、填充、下划线展示。支持自定义背景和文本样式
Stars: ✭ 25 (-79.84%)
Mutual labels:  password
pbkdf2-hmac-sha256
sha256, hmac with sha256 and pbkdf2 with hmac-sha256 in one header file
Stars: ✭ 19 (-84.68%)
Mutual labels:  pbkdf2
chrome-thief
A small program, lists all the stored user name and passwords with urls in Google Chrome.
Stars: ✭ 14 (-88.71%)
Mutual labels:  password
vietnamese-password-dicts
Tổng hợp danh sách mật khẩu wifi tiếng Việt sử dụng cho aircrack-ng
Stars: ✭ 40 (-67.74%)
Mutual labels:  password
SecureSnaps
Image Codec using Private-key cryptography
Stars: ✭ 13 (-89.52%)
Mutual labels:  aes-encryption
javascript-strong-password-generator
JavaScript Strong Password Generator: based on Jeff Atwood's Post "Password Rules Are Bullshit".
Stars: ✭ 21 (-83.06%)
Mutual labels:  password
crypto
Aplus Framework Crypto Library
Stars: ✭ 20 (-83.87%)
Mutual labels:  password
keevault
Kee Vault is a password manager for your web browser. Password databases (Vaults) are encrypted using the KeePass storage format before being sent to a remote server for synchronisation across any modern device/browser
Stars: ✭ 57 (-54.03%)
Mutual labels:  password
jlsca-tutorials
Tutorials and examples on how to use Jlsca, the high-performance side channel analysis toolkit written in Julia
Stars: ✭ 43 (-65.32%)
Mutual labels:  cryptography-tools
mysql-user-db-creator-bash-script
Script to create a mysql database, user and password with just a command
Stars: ✭ 24 (-80.65%)
Mutual labels:  password
WPA2-FritzBox-Pswd-Wordlist-Generator
This Script will produce all of the WPA2 Passwords used by various Router companies aswell as Fritzbox. All of these Passwords will be 16 Numbers in length. So it could get a bit large.
Stars: ✭ 22 (-82.26%)
Mutual labels:  password
crimson-spray
A lockout aware password sprayer
Stars: ✭ 11 (-91.13%)
Mutual labels:  password
mbedcrypto
a portable, small, easy to use and fast c++14 library for cryptography.
Stars: ✭ 38 (-69.35%)
Mutual labels:  aes-encryption
archiver-zip-encrypted
Plugin for archiver to create ZIP archives with password using either AES or legacy Zip 2.0 encryption
Stars: ✭ 50 (-59.68%)
Mutual labels:  password
Keepwords
📱🔐 Need an iOS password managing app with no pods? We got you covered!
Stars: ✭ 17 (-86.29%)
Mutual labels:  password

🔐 PageCrypt - Password Protected 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!

Get started

NOTE: Make sure you are using Node.js v16 or newer.

npm i -D pagecrypt

There are 4 different ways to use pagecrypt:

1. Encrypt HTML in modern browsers, Deno or Node.js using pagecrypt/core

The encryptHTML() and generatePassword() functions are using Web Crypto API and will thus be able to run in any ESM compatible environment that supports Web Crypto API.

This allows you to use the same pagecrypt API in any environment where you can run modern JavaScript.

encryptHTML(inputHTML: string, password: string, iterations?: number): Promise<string>

import { encryptHTML } from 'pagecrypt/core'

const inputHTML = `
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8">
        </head>
        <body>
            Secret
        </body>
    </html>
`

// 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(inputHTML, 'password')

// Optional: You can customize the number of password iterations if you want increased security.
const iterations = 3e6 // Same as 3_000_000
const customIterations = await encryptHTML(inputHTML, 'password', iterations)

generatePassword(length: number): string

import { generatePassword, encryptHTML } from 'pagecrypt/core'

// Generate a random password without any external dependencies
const password = generatePassword(64)
const encryptedHTML = await encryptHTML(inputHTML, password)

2. Node.js API

When working in a Node.js environment, you may prefer the pagecrypt Node.js build. This also includes the encrypt() function to read and write directly from and to the file system.

encrypt(inputFile: string, outputFile: string, password: string, iterations: number): Promise<void>

import { encrypt } from 'pagecrypt'

// Encrypt a HTML file and write to the filesystem
await encrypt('index.html', 'encrypted.html', 'password')

// You can optionally customize the number of password iterations
const iterations = 3e6 // Same as 3_000_000
await encrypt('index.html', 'encrypted.html', 'password', iterations)

NOTE: Importing pagecrypt also gives you access to generatePassword() and encryptHTML() from pagecrypt/core.

import { generatePassword, encryptHTML } from 'pagecrypt'

const password = generatePassword(48)
const iterations = 3e6 // Same as 3_000_000

const encrypted = await encryptHTML(inputHTML, password, iterations)

3. CLI

Encrypt a single HTML-file with one command:

npx pagecrypt <src> <dest> [password] [options]

Encrypt using a generated password with given length:

npx pagecrypt <src> <dest> -g <length>

3.1. CLI Help

  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.
    -i, --iterations           The number of password iterations.
    -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 index.html encrypted.html password --iterations 3e6
    $ pagecrypt index.html encrypted.html -g 64 --i 3e6

4. Automate pagecrypt in your build process

Use either the pagecrypt Node.js API or the CLI to automatically encrypt the builds for your single page applications.

npm i -D pagecrypt

package.json:

{
    "devDependencies": {
        "pagecrypt": "^5.0.0"
    },
    "scripts": {
        "build": "...",
        "postbuild": "pagecrypt index.html encrypted.html password"
    }
}

Deploying a SPA or Website Encrypted with pagecrypt

Since the output is a single HTML file, you can host it anywhere. This lets you bypass the need for server access to use HTTP basic authentication for password protection.

What this means in practice is that pagecrypt enables you to deploy private apps and websites to any static frontend hosting platform, often for free. Great for prototypes and client projects.

Share a Magic Link to Let Users Open Protected Pages With a Single Click

To make it easier for your users to access protected pages, you can create a magic link by adding # followed by your password to your deployment URL:

https://<link-to-your-page>#<password>

Then users can simply click the link to load the protected SPA or website - a really smooth UX! Just make sure to keep the link safe by sharing it via E2E-encrypted chats and emails.

How to Create a Magic Link

  1. Deploy your encrypted HTML file to any web server and copy the URL from your browser.
  2. Create the link by starting with your URL, then writing an #, followed by your password. E.g. https://example.com#password
  3. Make sure the link starts with the https:// protocol to keep users safe.

Since this magic link feature is using the URI Fragment, it will not be sent across the internet once the user clicks the link. Only the first part before the # leaves the user's computer to fetch the HTML page, and the rest remains in the browser, used for local decryption. Additionally, the fragment is removed from the browser address field when the page loads. However, beware that the password remains as a history entry if you use magic links!

Security Considerations

  • Most importantly, think twice about what kinds of sites and apps you publish to the open internet, even if they are encrypted.
  • If you use the magic link to login, beware that the password remains as a history entry! Feel free to submit a PR if you know a workaround for this!
  • Also keep in mind that the sessionStorage saves the encryption key (which is derived from the password) until the browser is restarted. This is what allows the rapid page reloads during the same session - at the cost of decreasing the security on your local device.
  • Only share magic links via secure channels, such as E2E-encrypted chats and emails.
  • pagecrypt only encrypts the contents of a single HTML file, so try to inline as much JS, CSS and other sensitive assets into this HTML file as possible. If you're unable to inline all sensitive assets, you can hide your other assets by placing them on another server, and then only reference the external resources within the pagecrypt protected HTML file instead. Of course, these could in turn be protected or hidden if you need to. If executed correctly, this allows you to completely hide what your webpage or app is about by only deploying a single HTML file to the public web. Neat!

Development

Project structure:

  • /web - Web frontend for public webpage (decrypt-template.html).
  • /src/core.ts - pagecrypt core library.
  • /src/index.ts - pagecrypt Node.js library.
  • /src/cli.ts - pagecrypt CLI.
  • /test - simple testing setup.
  • /scripts - local scripts for development tasks.

Setup a local development environment

  1. Install Node.js >= 16.0.0
  2. Run npm install in project root.

Testing

First do one of the following:

  • npm test to run the tests.
  • npm run test:build to first build a new version of pagecrypt and then run the tests.

Then run npm run verify in another terminal and verify the test results at http://localhost:3000.

On the test results page you will find links to open output files in new tabs, buttons to copy passwords, and a special # link to verify that magic links decrypt the page immediately when the page loads.

To test pagecrypt/core and verify encryption in the browser, use the button at the bottom of the list. Download the file and then copy the password by clicking the button again to decrypt it. If you save the file to the same directory as the other generated files, you can use the links just like for other results. Use the reset button to encrypt another file.


Welcome to submit issues and pull requests!

License

AGPL-3.0

Copyright (c) 2015 Maximillian Laumeister Copyright (c) 2021-2023 Samuel Plumppu

This is a complete rewrite of the MIT-licensed PageCrypt created by Maximillian Laumeister.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].