|
@@ -1,39 +1,48 @@
|
|
# Hugo Encryptor
|
|
# Hugo Encryptor
|
|
|
|
|
|
-**Hugo-Encryptor** is a tool to protect your [Hugo](https://gohugo.io) posts. It uses AES-128 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-Encryptor** is a tool to protect your [Hugo](https://gohugo.io) 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.
|
|
|
|
+
|
|
|
|
+[中文文档](./README-zh_CN.md)
|
|
|
|
+
|
|
|
|
+[TOC]
|
|
|
|
|
|
## Installation
|
|
## Installation
|
|
|
|
|
|
-Step 1: Install all the requirements of Hugo-Encryptor.
|
|
|
|
|
|
+Environmental dependence: Python3
|
|
|
|
+
|
|
|
|
+**Step 1: Install all the requirements of Hugo-Encryptor.**
|
|
|
|
|
|
|
|
+ $ git clone https://github.com/Li4n0/hugo_encryptor.git
|
|
$ cd Hugo-Encryptor
|
|
$ cd Hugo-Encryptor
|
|
$ pip install -r requirements.txt
|
|
$ pip install -r requirements.txt
|
|
|
|
|
|
-Step 2: Place `hugo-encryptor.py` somewhere in the directory of your blog.
|
|
|
|
|
|
+**Step 2: Place `hugo-encryptor.py` in the root directory of your blog.**
|
|
|
|
|
|
$ cp hugo-encryptor.py /path/to/your/blog/hugo-encryptor.py
|
|
$ cp hugo-encryptor.py /path/to/your/blog/hugo-encryptor.py
|
|
|
|
|
|
-Step 3: Install our Hugo shortcodes file into your blog:
|
|
|
|
|
|
+**Step 3: Place `shortcodes/hugo-encryptor.html` in the shortcode directory of your blog:**
|
|
|
|
|
|
$ mkdir -p /path/to/your/blog/layouts/shortcodes
|
|
$ mkdir -p /path/to/your/blog/layouts/shortcodes
|
|
$ cp shortcodes/hugo-encryptor.html /path/to/your/blog/layouts/shortcodes/hugo-encryptor.html
|
|
$ cp shortcodes/hugo-encryptor.html /path/to/your/blog/layouts/shortcodes/hugo-encryptor.html
|
|
|
|
|
|
## Usage
|
|
## Usage
|
|
|
|
|
|
-A typical way to use Hugo-Encryptor has been already uploaded in [example_site](example_site).
|
|
|
|
|
|
+**Step 1: Use `hugo-encryptor` tag surround the text you want to encrypt **
|
|
|
|
|
|
-**Step 1: Call our `hugo-encryptor` shortcodes if you want to encrypt a very post**
|
|
|
|
|
|
+**Attention! There must be some text and the `<!--more-->` tag before the hugo-encryptor:**
|
|
|
|
|
|
```markdown
|
|
```markdown
|
|
---
|
|
---
|
|
-title: This Is An Encrypted Post
|
|
|
|
|
|
+title: "This Is An Encrypted Post"
|
|
---
|
|
---
|
|
|
|
|
|
|
|
+**There must be some text, and the summary tag is also needed:**
|
|
|
|
+<!--more-->
|
|
{{% hugo-encryptor "PASSWORD" %}}
|
|
{{% hugo-encryptor "PASSWORD" %}}
|
|
|
|
|
|
# You cannot see me unless you've got the password!
|
|
# You cannot see me unless you've got the password!
|
|
|
|
|
|
-This is the content of my private post!
|
|
|
|
|
|
+This is the content you want to encrypt!
|
|
|
|
|
|
**Do remember to close the `hugo-encryptor` shortcodes tag:**
|
|
**Do remember to close the `hugo-encryptor` shortcodes tag:**
|
|
|
|
|
|
@@ -48,11 +57,59 @@ It may be something like:
|
|
|
|
|
|
**Step 3: Get the encryption done!**
|
|
**Step 3: Get the encryption done!**
|
|
|
|
|
|
- $ python hugo-encryptor.py --path /path/to/your/blog/public
|
|
|
|
|
|
+ $ python hugo-encryptor.py
|
|
|
|
|
|
Then all the private posts in your `public` directory would be encrypted thoroughly, congrats!
|
|
Then all the private posts in your `public` directory would be encrypted thoroughly, congrats!
|
|
|
|
|
|
|
|
+## Configuration
|
|
|
|
+
|
|
|
|
+Although the **Hugo-Encryptor** can run without any configure, we provide some settings params to help you configure **Hugo-Encryptor** to your liking.
|
|
|
|
+
|
|
|
|
+### Language
|
|
|
|
+
|
|
|
|
+As default,**Hugo-Encryptor** displays in Chinese, by adding `hugoEncryptorLanguage` param in your blog's config file, you can change the language into English. Such as below:
|
|
|
|
+
|
|
|
|
+```toml
|
|
|
|
+[params]
|
|
|
|
+ ......
|
|
|
|
+ hugoEncryptorLanguage = "en-us" # or "zh-cn"
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### The way of client password storage
|
|
|
|
+
|
|
|
|
+As default,**Hugo-Encryptor** use `localStorage` to storage the password's md5 in client. By adding `hugoEncryptorStorage` param in your blog's config file, you can change the storage method into `sessionStorage`. Such as below:
|
|
|
|
+
|
|
|
|
+```toml
|
|
|
|
+[params]
|
|
|
|
+ ......
|
|
|
|
+ hugoEncryptorStorage = "session" # or "local"
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+For the difference of two storage ways:
|
|
|
|
+
|
|
|
|
+* **localStorage**:
|
|
|
|
+
|
|
|
|
+ Once a user input the correct password,the authorization status will not expire, the user can read the article at any time without having to enter the password again. Unless you change the password or the user clean his browser cache.
|
|
|
|
+
|
|
|
|
+* **sessionStorage**:
|
|
|
|
+
|
|
|
|
+ If a user input the correct password, he could read the article without having to enter the password again until the user close his browser.
|
|
|
|
+
|
|
|
|
+### Style
|
|
|
|
+
|
|
|
|
+As default, **Hugo-Encryptor** has no style,but we have already give all the visual element a class name, you can add style for them in your css files.
|
|
|
|
+
|
|
## Attentions
|
|
## Attentions
|
|
|
|
|
|
-* Do remember to keep the source code of your encrypted posts private. A typical way to deal with them is to ignore them by adding `content/posts/` in your `.gitignore` file.
|
|
|
|
|
|
+* 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 `$ python hugo-encryptor` again to encrypt the posts which you want to be protected. If you are worried about you will forgot that, it's a good idea to use a shell script to take the place of `$ hugo` ,such as below:
|
|
|
|
+
|
|
|
|
+ ```bash
|
|
|
|
+ #!/bin/bash
|
|
|
|
+ hugo
|
|
|
|
+ python hugo-encryptor
|
|
|
|
+ ```
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|