{"id":13399407,"url":"https://github.com/derhuerst/self-decrypting-html-page","last_synced_at":"2025-04-13T00:11:49.715Z","repository":{"id":65493861,"uuid":"108201537","full_name":"derhuerst/self-decrypting-html-page","owner":"derhuerst","description":"Generate a standalone HTML page that decrypts data.","archived":false,"fork":false,"pushed_at":"2025-02-18T13:15:03.000Z","size":64,"stargazers_count":34,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T00:11:44.804Z","etag":null,"topics":["decrypt","encrypt","html","libsodium","secret","sodium"],"latest_commit_sha":null,"homepage":"https://github.com/derhuerst/self-decrypting-html-page#self-decrypting-html-page","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derhuerst.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-25T01:01:51.000Z","updated_at":"2025-02-18T13:15:03.000Z","dependencies_parsed_at":"2024-01-18T11:03:20.427Z","dependency_job_id":"6db1c045-afcb-48c4-80f5-64693409089c","html_url":"https://github.com/derhuerst/self-decrypting-html-page","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.05555555555555558,"last_synced_commit":"4f8154c14dad3e0f51aa485e40ad10a25f84f8d4"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fself-decrypting-html-page","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fself-decrypting-html-page/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fself-decrypting-html-page/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fself-decrypting-html-page/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derhuerst","download_url":"https://codeload.github.com/derhuerst/self-decrypting-html-page/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647278,"owners_count":21139086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decrypt","encrypt","html","libsodium","secret","sodium"],"created_at":"2024-07-30T19:00:37.416Z","updated_at":"2025-04-13T00:11:49.709Z","avatar_url":"https://github.com/derhuerst.png","language":"JavaScript","funding_links":["https://github.com/sponsors/derhuerst"],"categories":["JavaScript"],"sub_categories":[],"readme":"# self-decrypting-html-page\n\n**Generate a standalone HTML page that decrypts an encrypted message.** Used by [`html-vault`](https://github.com/derhuerst/html-vault#html-vault-).\n\n[![npm version](https://img.shields.io/npm/v/self-decrypting-html-page.svg)](https://www.npmjs.com/package/self-decrypting-html-page)\n![ISC-licensed](https://img.shields.io/github/license/derhuerst/self-decrypting-html-page.svg)\n[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)\n[![chat with me on Twitter](https://img.shields.io/badge/chat%20with%20me-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)\n\nThe idea is to have a tool that encrypts any message/secret and generates something that can *decrypt itself*. I see two advantages of the HTML-based solution over others:\n\n- **low entry-barrier**: Everyone has a web browser. Everyone with a reasonably modern browser will be able to use the tool, without installing anything. It is also more platform-independent than other solutions.\n- **self-contained**: The generated page has all the logic built-in that it needs to decrypt the encrypted message. It can be stored as a standalone file.\n\nWith `self-decrypting-html-page`, you can use this functionality anywhere. Consider the examples below.\n\n\n## Usage from the command line\n\nThere are three ways to install this tool:\n\n- standalone binaries from the [releases page](/derhuerst/self-decrypting-html-page/releases)\n- installing globally using [npm](https://docs.npmjs.com/cli/npm): `npm install -g self-decrypting-html-page`\n- temporarily installing it into a temp directory and running it, using [npx](https://npmjs.com/package/npx): `npx self-decrypting-html-page`\n\n```shell\n# basic usage\necho 'my secret message' | npx self-decrypting-html-page \u003eencrypted-message.html\n# This is your key:\n# 964d87e28a7f468afe33c255e689d2baa5d67dabc43d6262971a5efd18917929\n\n# write decryption key to file\necho 'my secret message' | npx self-decrypting-html-page \u003eencrypted-message.html 2\u003ekey.txt\ncat key.txt\n# 964d87e28a7f468afe33c255e689d2baa5d67dabc43d6262971a5efd18917929\n```\n\n\n## Usage with JS\n\n```shell\nnpm i self-decrypting-html-page\n```\n\n```js\nconst encryption = require('sodium-encryption')\nconst generateHTML = require('self-decrypting-html-page')\n\nconst msg = Buffer.from('super secret message')\nconst key = encryption.key()\nconsole.log('key:', key.toString('hex'))\n\nconst nonce = encryption.nonce()\nconst encrypted = encryption.encrypt(msg, nonce, key)\nconst html = generateHTML(nonce, encrypted)\n// write this HTML to a file, open in the browser\n```\n\n\n## Usage with custom HTML template\n\nWrite the template for self-decrypting HTML page. Check [`decrypt.html`](decrypt.html) for the necessary elements.\n\nGenerating a custom self-decrypting HTML page from the command line:\n\n```shell\necho 'my secret message' | npx self-decrypting-html-page --html path/to/template.html \u003eencrypted-message.html\n```\n\nGenerating a it using JS:\n\n```js\nconst {readFileSync} = require('fs')\nconst {join} = require('path')\nconst generateHTML = require('self-decrypting-html-page/custom-html')\n\nconst template = readFileSync(join(__dirname, 'template.html'))\nconst html = generateHTML(nonce, encrypted, template)\n```\n\n\n## How it works\n\n- [`lib/decrypt.js`](lib/decrypt.js) contains the logic to decrypt the message, using the nonce and the password entered by the user.\n- [`lib/decrypt.js` gets bundled with all its dependencies and stored in `decrypt.js`](https://github.com/derhuerst/self-decrypting-html-page/blob/546b4d9a6d9694df4fe498bdc53288216fa224a0/package.json#L36), using [Browserify](http://browserify.org).\n- Then, using [brfs](https://www.npmjs.com/package/brfs), [the generated bundle will be inserted](https://github.com/derhuerst/self-decrypting-html-page/blob/546b4d9a6d9694df4fe498bdc53288216fa224a0/package.json#L37) into another JS file `generate.js`. The version of `self-decrypting-html-page` published to npm already contains it.\n- When you call `generateHTML(nonce, encrypted)` or run it from the command line, it will replace placeholders in the HTML (that already contains the code to decrypt) and give the final string back to you.\n\n\n## Contributing\n\nIf you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/self-decrypting-html-page/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fself-decrypting-html-page","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderhuerst%2Fself-decrypting-html-page","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fself-decrypting-html-page/lists"}