Giter Club home page Giter Club logo

self-decrypting-html-page's Introduction

self-decrypting-html-page

Generate a standalone HTML page that decrypts an encrypted message. Used by html-vault.

npm version build status ISC-licensed support me via GitHub Sponsors chat with me on Twitter

The 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:

  • 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.
  • 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.

With self-decrypting-html-page, you can use this functionality anywhere. Consider the examples below.

Usage from the command line

There are three ways to install this tool:

  • standalone binaries from the releases page
  • installing globally using npm: npm install -g self-decrypting-html-page
  • temporarily installing it into a temp directory and running it, using npx: npx self-decrypting-html-page
# basic usage
echo 'my secret message' | npx self-decrypting-html-page >encrypted-message.html
# This is your key:
# 964d87e28a7f468afe33c255e689d2baa5d67dabc43d6262971a5efd18917929

# write decryption key to file
echo 'my secret message' | npx self-decrypting-html-page >encrypted-message.html 2>key.txt
cat key.txt
# 964d87e28a7f468afe33c255e689d2baa5d67dabc43d6262971a5efd18917929

Usage with JS

npm i self-decrypting-html-page
const encryption = require('sodium-encryption')
const generateHTML = require('self-decrypting-html-page')

const msg = Buffer.from('super secret message')
const key = encryption.key()
console.log('key:', key.toString('hex'))

const nonce = encryption.nonce()
const encrypted = encryption.encrypt(msg, nonce, key)
const html = generateHTML(nonce, encrypted)
// write this HTML to a file, open in the browser

Usage with custom HTML template

Write the template for self-decrypting HTML page. Check decrypt.html for the necessary elements.

Generating a custom self-decrypting HTML page from the command line:

echo 'my secret message' | npx self-decrypting-html-page --html path/to/template.html >encrypted-message.html

Generating a it using JS:

const {readFileSync} = require('fs')
const {join} = require('path')
const generateHTML = require('self-decrypting-html-page/custom-html')

const template = readFileSync(join(__dirname, 'template.html'))
const html = generateHTML(nonce, encrypted, template)

How it works

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.

self-decrypting-html-page's People

Contributors

ambujsahu81 avatar derhuerst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

self-decrypting-html-page's Issues

Use Case

Could you provide a use case for this script? I don't understand how it works and can be used.

Decrypt with URL parameter?

Would it be possible to create a version of this where the page decrypts itself if the key is provided as a URL parameter or anchor?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.