Coder Social home page Coder Social logo

adityatelange / hugo_enc Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 86 KB

A python3 CLI package to encrypt Hugo posts

License: MIT License

Python 65.16% HTML 8.87% JavaScript 25.97%
hugo-encryptor hugo python3 crypto-js password-protection encryption-tool

hugo_enc's Introduction

Hugo Enc (Encryptor) ๐Ÿ”

Note: This is a fork of https://github.com/Li4n0/hugo_encryptor

Hugo Enc is a tool to protect your Hugo posts. It uses AES-256 to encrypt the contents of your posts, and inserts a snippet of <script> code to verify whether the password is correct or not in readers' browser. Without a correct key, nobody can decrypt your private posts.

Hugo Enc currently works with HTML, XML and JSON outputs.


Installation ๐Ÿ“ฅ

Requirements

  • Python3

Step 1: Clone Hugo-Enc

  1. Change your directory to your website source

    $ cd to/your/hugo/website/source
  2. Install hugo_enc as a submodule

    $ git submodule add https://github.com/adityatelange/hugo_enc themes/hugo_enc --depth=1
  3. Add hugo_enc as a theme

    In your config.yml add hugo_enc in themes variable ex.

    theme: [MyTheme, hugo_enc]

Step 2: Install Hugo-Enc

$ cd themes/hugo_enc
$ pip3 install .

Usage โ„น๏ธ

Wrap the text you want to encrypt with the tag hugo_enc

Note: Some text is required before you actually start the encrypting part, with a tag <!--more--> placed in the middle of them. Example:**

---
title: "A Post which has encrypted content"
---

Some text is required to be placed here.

<!--more-->

{{< hugo_enc "PASSWORD" >}}

This is the content you want to encrypt!

{{</ hugo_enc >}}

Usage for hugo_enc

Usage:
        hugo_enc [flags]

Flags:
    -h, --help              -           get help about hugo_enc
        --scriptURL         string      override the default 'scriptURL' to load crypto-js
        --destination       string      set the output folder (default: 'public')

Step 1: Generate your site

Go to your website's root and generate it as usual.

For ex.

$ hugo

Step 2: Encrypt your posts

The following command will encrypt all the blocks with hugo_enc with provided password

$ hugo_enc

Style ๐ŸŽ€

Hugo Encryptor has no style elements attached to it.

However, it has some classes which you can use to customize it accordingly.

View the template here => layouts/shortcodes/hugo_enc.html


Adding custom Text to hugo_enc shortcode

You can use the following params in your site config.yml:

Params:
    hugoEnc:
        promptText: "Part of this article is encrypted with password:"
        inputPlaceholder: "Please input the password"
        buttonText: "Unlock"

Note โš ๏ธ

  • Do remember to keep the source code of your encrypted posts private. Never push your blog directory into a public repository.

  • Every time when you generate your site, you should run hugo_enc again to encrypt the posts which you want to be protected. If you are worried about you will forget that, it's a good idea to use a shell script to take the place of hugo,such as below:

    #!/bin/bash
    
    hugo
    hugo_enc
    # Then upload your generated output

hugo_enc's People

Contributors

adityatelange avatar dependabot[bot] avatar derbalkon avatar hly0928 avatar li4n0 avatar oyiadin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

r3pek

hugo_enc's Issues

Content decrypted without format.

hello, when I put the password the content is decrypted satisfactorily but without the html format.

Am I doing something wrong, any advice?
I am using Hugo's zzo theme.

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.