hexo-blog-encrypt 4.0.3 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReadMe.md +44 -343
- package/ReadMe.zh.md +44 -337
- package/lib/hbe.blink.html +10 -9
- package/lib/hbe.bundle.js +1 -1
- package/lib/hbe.bundle.js.map +4 -4
- package/lib/hbe.card.html +24 -0
- package/lib/hbe.default.html +10 -9
- package/lib/hbe.flip.html +10 -9
- package/lib/hbe.minimal.html +24 -0
- package/lib/hbe.shrink.html +9 -9
- package/lib/hbe.style.css +557 -827
- package/lib/hbe.surge.html +15 -12
- package/lib/hbe.terminal.html +24 -0
- package/lib/hbe.up.html +10 -9
- package/lib/hbe.wave.html +14 -12
- package/lib/hbe.xray.html +15 -13
- package/package.json +19 -10
- package/src/server/config.js +145 -23
- package/src/server/crypto.js +52 -55
- package/src/server/format.js +77 -0
- package/src/server/generator.js +40 -63
- package/src/server/index.js +20 -15
- package/src/server/template.js +2 -1
package/ReadMe.md
CHANGED
|
@@ -1,378 +1,79 @@
|
|
|
1
1
|
# hexo-blog-encrypt
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/hexo-blog-encrypt)
|
|
5
|
-
[](https://www.npmjs.com/package/hexo-blog-encrypt)
|
|
6
|
-
[](./LICENSE)
|
|
7
|
-
[](https://github.com/D0n9X1n/hexo-blog-encrypt/actions/workflows/test.yml)
|
|
8
|
-
[](https://d0n9x1n.github.io/hexo-blog-encrypt/)
|
|
9
|
-
|
|
10
|
-
[中文说明](./ReadMe.zh.md)
|
|
11
|
-
|
|
12
|
-
## What's this
|
|
13
|
-
|
|
14
|
-
- ~~First of all, the **BEST** post encryption plugin in the universe for hexo.(But what about the other plugins?)~~
|
|
15
|
-
|
|
16
|
-
- It is for those who write a post, but don't want everyone to read it. Thus, password is required in certain pages to access these encrypted posts.
|
|
17
|
-
|
|
18
|
-
- Encryption is simple on wordpress, emlog or other blog systems, except hexo. :(
|
|
19
|
-
|
|
20
|
-
- So it's "hexo-blog-encrypt"'s time.
|
|
21
|
-
|
|
22
|
-
## Features
|
|
23
|
-
|
|
24
|
-
- Once you enter the correct password, the encrypted post is decrypted client-side. By default the password is **not** persisted; opt in with `autoSave: true` (per-post or in `_config.yml`) to have a derived key cached in `localStorage` so a subsequent reload of the same page auto-decrypts. If there are scripts in the post, they will be executed once the post is decrypted.
|
|
25
|
-
|
|
26
|
-
- Support preset tag-specified password.
|
|
27
|
-
|
|
28
|
-
- All functions are provided by the native APIs. We use [Crypto](https://nodejs.org/dist/latest-v12.x/docs/api/crypto.html) in Node.js, and use [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) in Browsers.
|
|
29
|
-
|
|
30
|
-
- [PBKDF2](https://tools.ietf.org/html/rfc2898) with [SHA-256](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) is used to derive keys, and we use [AES-256-GCM](https://csrc.nist.gov/publications/detail/sp/800-38d/final) for both encryption and authenticated decryption — the GCM auth tag detects any modification of the ciphertext (replacing the v3 separate HMAC step).
|
|
31
|
-
|
|
32
|
-
- Promise is widely used to make sure our main procedures are asynchronous, so that there is little chance for the process to be blocked, and the experience will be more fluent.
|
|
33
|
-
|
|
34
|
-
- Template theme supported, you can use [`default`, `blink`, `flip`, `shrink`, `surge`, `up`, `wave`, `xray`] to set up your template theme, and [CHECK ONLINE](https://d0n9x1n.github.io/hexo-blog-encrypt/tags/theme-demo/).
|
|
35
|
-
|
|
36
|
-
- Outdated browsers may not work well. In such case, please upgrade your browser.
|
|
37
|
-
|
|
38
|
-
## Online demo
|
|
39
|
-
|
|
40
|
-
- See [Demo Page](https://d0n9x1n.github.io/hexo-blog-encrypt/), **all passwords are `hello`**.
|
|
41
|
-
|
|
42
|
-
## Browser support
|
|
43
|
-
|
|
44
|
-
The runtime uses Web Crypto (`crypto.subtle`), which requires a **secure
|
|
45
|
-
context** (HTTPS or `http://localhost`). Verified:
|
|
46
|
-
|
|
47
|
-
| Browser | Minimum | Notes |
|
|
48
|
-
| --- | --- | --- |
|
|
49
|
-
| Chromium / Edge | 92+ | Tested in CI via Playwright |
|
|
50
|
-
| Firefox | 90+ | |
|
|
51
|
-
| Safari (macOS / iOS) | 14+ | Manual smoke at release time |
|
|
52
|
-
|
|
53
|
-
If your site is served over plain HTTP from a non-localhost host,
|
|
54
|
-
decryption will silently fail (`crypto.subtle` is `undefined`). Always
|
|
55
|
-
use HTTPS in production.
|
|
56
|
-
|
|
57
|
-
## Why upgrade from v3?
|
|
58
|
-
|
|
59
|
-
v4 isn't a cosmetic refresh — it closes real security gaps and fixes UX
|
|
60
|
-
problems v3 had. The headline reasons:
|
|
3
|
+
Keep a post on your static Hexo blog, but share its contents only with readers who know the password. Hexo encrypts the body when you build; readers unlock it in their browser. No accounts or decryption server needed.
|
|
61
4
|
|
|
62
|
-
|
|
63
|
-
tag replaces v3's AES-CBC + separate HMAC. One primitive, one auth
|
|
64
|
-
path, hardware-accelerated, and immune to a class of CBC
|
|
65
|
-
padding-oracle and HMAC-comparison bugs.
|
|
66
|
-
- **Per-post salt + nonce.** v3 used the same salt for every post, so
|
|
67
|
-
the same password derived the same key everywhere. v4 derives an
|
|
68
|
-
independent key per post — an attacker can't amortize one password's
|
|
69
|
-
PBKDF2 work across other posts that share the password.
|
|
70
|
-
- **Stronger KDF defaults.** v3 used **1,024** PBKDF2-SHA256 iterations
|
|
71
|
-
— far below current recommendations and easily amortized across many
|
|
72
|
-
guesses on modern hardware. v4 defaults to **250,000** (≈ 240× more
|
|
73
|
-
work per guess) and recommends 600,000+ (OWASP 2023). Tunable per
|
|
74
|
-
post via `kdf.iterations`.
|
|
75
|
-
- **Privacy by default.** v3 always cached decrypted posts in
|
|
76
|
-
`localStorage`, so anyone with subsequent device access could
|
|
77
|
-
re-read them. v4 defaults to `autoSave: false`; you opt in per post
|
|
78
|
-
or globally.
|
|
79
|
-
- **Inline error messages.** v3 fired a `window.alert()` dialog on a
|
|
80
|
-
wrong password — disruptive, especially on mobile. v4 shows the
|
|
81
|
-
error inline next to the password field (`role="alert"`).
|
|
82
|
-
- **Optional click-to-decrypt button.** Discoverable for visitors who
|
|
83
|
-
don't realise Enter submits the form. Label is configurable.
|
|
84
|
-
- **Smaller bundle.** Drops the bundled CryptoJS dependency in
|
|
85
|
-
favour of the browser's native Web Crypto API. The shipped browser
|
|
86
|
-
bundle is ≈ 6 KB minified.
|
|
87
|
-
- **Tested.** Server suite at 100 % line / branch / function coverage
|
|
88
|
-
+ Playwright e2e across all 8 themes. v3 had effectively zero
|
|
89
|
-
automated tests; v4 is regression-guarded on every push.
|
|
5
|
+
**[Try a locked post](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/card/)** (demo password: `hello`) · [Read the guide](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Getting-Started) · [简体中文](https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/ReadMe.zh.md)
|
|
90
6
|
|
|
91
|
-
|
|
92
|
-
HTML, or about shared-device exposure of cached keys — upgrade.
|
|
7
|
+
[](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/card/)
|
|
93
8
|
|
|
94
|
-
|
|
95
|
-
[
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
v4 changed the wire format (AES-GCM, per-post salt + nonce). Existing
|
|
100
|
-
encrypted output cannot be read by v4 and vice versa, so:
|
|
101
|
-
|
|
102
|
-
1. Upgrade the plugin: `npm install --save hexo-blog-encrypt@^4`.
|
|
103
|
-
2. Rebuild from source: `hexo clean && hexo generate`.
|
|
104
|
-
3. Purge your CDN if you use one (the post HTML changes byte-for-byte
|
|
105
|
-
on every build by design — fresh nonce per encryption — but the
|
|
106
|
-
runtime asset URL `lib/hbe.<hash>.js` is content-hashed and only
|
|
107
|
-
changes when the bundle changes).
|
|
108
|
-
4. Optional: drop `wrong_hash_message` from your config and front-matter
|
|
109
|
-
(deprecated in v4, removed in v5).
|
|
110
|
-
|
|
111
|
-
No source `.md` files are touched. See [CHANGELOG.md](./CHANGELOG.md)
|
|
112
|
-
for the full breaking-changes list and the new `decryptButton` /
|
|
113
|
-
`autoSave` / `kdf.iterations` options.
|
|
114
|
-
|
|
115
|
-
## Install
|
|
116
|
-
|
|
117
|
-
- `npm install --save hexo-blog-encrypt`
|
|
118
|
-
|
|
119
|
-
- or `yarn add hexo-blog-encrypt` (require [Yarn](https://yarnpkg.com/en/))
|
|
120
|
-
|
|
121
|
-
## Quick start
|
|
122
|
-
|
|
123
|
-
- Add the "password" value to your post's front matter like:
|
|
9
|
+
[](https://github.com/D0n9X1n/hexo-blog-encrypt/releases)
|
|
10
|
+
[](https://www.npmjs.com/package/hexo-blog-encrypt)
|
|
11
|
+
[](https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/LICENSE)
|
|
12
|
+
[](https://github.com/D0n9X1n/hexo-blog-encrypt/actions/workflows/test.yml)
|
|
13
|
+
[](https://d0n9x1n.github.io/hexo-blog-encrypt/)
|
|
124
14
|
|
|
125
|
-
|
|
15
|
+
## Lock your first post
|
|
126
16
|
|
|
127
|
-
|
|
128
|
-
title: Hello World
|
|
129
|
-
date: 2016-03-30 21:18:02
|
|
130
|
-
password: hello
|
|
131
|
-
---
|
|
17
|
+
From your Hexo site directory (Node.js 18+, Hexo 5+):
|
|
132
18
|
|
|
19
|
+
```sh
|
|
20
|
+
npm install --save hexo-blog-encrypt
|
|
133
21
|
```
|
|
134
22
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
## Password Priority
|
|
138
|
-
|
|
139
|
-
post's front matter > encrypt tags
|
|
140
|
-
|
|
141
|
-
## Advanced settings
|
|
142
|
-
|
|
143
|
-
### in post's front matter
|
|
144
|
-
|
|
145
|
-
```markdown
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
title: Hello World
|
|
149
|
-
tags:
|
|
150
|
-
- encryptAsDiary
|
|
151
|
-
date: 2016-03-30 21:12:21
|
|
152
|
-
password: mikemessi
|
|
153
|
-
abstract: Here's something encrypted, password is required to continue reading.
|
|
154
|
-
message: Hey, password is required here.
|
|
155
|
-
wrong_pass_message: Oh, this is an invalid password. Check and try again, please.
|
|
156
|
-
# Deprecated under v4 — AES-GCM unifies wrong-password and tampered-ciphertext
|
|
157
|
-
# failures, so this option is now an alias of `wrong_pass_message`. Set
|
|
158
|
-
# `wrong_pass_message` instead.
|
|
159
|
-
wrong_hash_message: Oh, these decrypted content cannot be verified, but you can still have a look.
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### In `_config.yml`
|
|
165
|
-
|
|
166
|
-
#### Example
|
|
23
|
+
Add a password to the front matter of **one** post. Use a long, unique passphrase instead of the demo password.
|
|
167
24
|
|
|
168
25
|
```yaml
|
|
169
|
-
# Security
|
|
170
|
-
encrypt: # hexo-blog-encrypt
|
|
171
|
-
abstract: Here's something encrypted, password is required to continue reading.
|
|
172
|
-
message: Hey, password is required here.
|
|
173
|
-
tags:
|
|
174
|
-
- {name: encryptAsDiary, password: passwordA}
|
|
175
|
-
- {name: encryptAsTips, password: passwordB}
|
|
176
|
-
wrong_pass_message: Oh, this is an invalid password. Check and try again, please.
|
|
177
|
-
# Deprecated under v4 (alias of `wrong_pass_message`). See note above.
|
|
178
|
-
wrong_hash_message: Oh, these decrypted content cannot be verified, but you can still have a look.
|
|
179
|
-
|
|
180
|
-
# ── v4 keys (all optional, safe defaults) ────────────────────────────
|
|
181
|
-
# Render a visible "Decrypt" button next to the password field.
|
|
182
|
-
# Themes that already include a button via `<%- decrypt_button %>`
|
|
183
|
-
# ignore this option. Default: true.
|
|
184
|
-
decryptButton:
|
|
185
|
-
show: true
|
|
186
|
-
text: Decrypt
|
|
187
|
-
|
|
188
|
-
# Cache the derived AES key in localStorage so reloads skip the password
|
|
189
|
-
# prompt. OFF by default — opt in per post via front-matter
|
|
190
|
-
# `autoSave: true`, or globally here. Cache key is namespaced under
|
|
191
|
-
# `hbe.v4.<post-permalink-hash>`.
|
|
192
|
-
autoSave: false
|
|
193
|
-
|
|
194
|
-
# Keep the PBKDF2 salt stable across clean static builds for the same
|
|
195
|
-
# post permalink. Default: false. This is useful with autoSave on
|
|
196
|
-
# Cloudflare Pages, Vercel, Netlify, GitHub Actions, and similar
|
|
197
|
-
# platforms that rebuild generated HTML from a clean environment on
|
|
198
|
-
# every deploy.
|
|
199
|
-
#
|
|
200
|
-
# Only the salt is stable. The AES-GCM nonce remains random for every
|
|
201
|
-
# encryption to avoid nonce reuse. If the post permalink changes, the
|
|
202
|
-
# stable salt changes too, and existing localStorage cache for that page
|
|
203
|
-
# is invalidated.
|
|
204
|
-
stableSalt: false
|
|
205
|
-
|
|
206
|
-
# PBKDF2 iteration count. Floor: 100_000. Recommended ≥ 600_000
|
|
207
|
-
# (OWASP 2023 for PBKDF2-SHA256). Lower-than-recommended values log a
|
|
208
|
-
# warning at build time. Default: 250_000.
|
|
209
|
-
kdf:
|
|
210
|
-
iterations: 250000
|
|
211
|
-
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
When `autoSave` reads a cached key, it compares the cached salt with the
|
|
215
|
-
current page salt. A nonce change alone does not delete the cache up
|
|
216
|
-
front; the browser tries the cached key with the current page nonce and
|
|
217
|
-
ciphertext. If AES-GCM authentication fails, the cache entry is cleared
|
|
218
|
-
and the visitor is asked for the password again.
|
|
219
|
-
|
|
220
|
-
#### To disable tag encryption
|
|
221
|
-
|
|
222
|
-
Just set the `password` property in front matter to `""`.
|
|
223
|
-
|
|
224
|
-
Example:
|
|
225
|
-
|
|
226
|
-
```
|
|
227
|
-
---
|
|
228
|
-
title: Callback Test
|
|
229
|
-
date: 2019-12-21 11:54:07
|
|
230
|
-
tags:
|
|
231
|
-
- A Tag should be encrypted
|
|
232
|
-
password: ""
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
Use a "" to disable tag encryption.
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Config priority
|
|
239
|
-
|
|
240
|
-
post's front matter > `_config.yml` (in the root directory) > default
|
|
241
|
-
|
|
242
|
-
### About Callback
|
|
243
|
-
In some blogs, some elements may not be displayed normally after decryption. This is a known issue. The current solution is to check the code in your blog to learn which functions are called when the onload event occurs.
|
|
244
|
-
Then write these code at the end of your post. For example:
|
|
245
|
-
|
|
246
|
-
```
|
|
247
26
|
---
|
|
248
|
-
title:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
27
|
+
title: Field notes
|
|
28
|
+
theme: wave
|
|
29
|
+
password: { env: POST_PASSWORD }
|
|
30
|
+
abstract: Notes from the trip. Ask me for the password.
|
|
252
31
|
---
|
|
253
|
-
|
|
254
|
-
This is a blog to test Callback functions. You just need to add code at the end of your post as follows:
|
|
255
|
-
|
|
256
|
-
It will be called after the blog is decrypted.
|
|
257
|
-
|
|
258
|
-
<script>
|
|
259
|
-
// add script tag and code at the end of your post
|
|
260
|
-
alert("Hello World");
|
|
261
|
-
</script>
|
|
262
32
|
```
|
|
263
33
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
### After Decrypt Event
|
|
267
|
-
|
|
268
|
-
The plugin dispatches `hexo-blog-decrypt` once on `window` after decryption.
|
|
269
|
-
`event.detail.mode` is `manual` (password entered) or `cached` (saved key).
|
|
270
|
-
Listen for the event rather than dispatching it yourself:
|
|
271
|
-
|
|
272
|
-
```js
|
|
273
|
-
window.addEventListener('hexo-blog-decrypt', function (event) {
|
|
274
|
-
// Reinitialize your theme's table of contents, syntax highlighting, etc.
|
|
275
|
-
console.log('Decrypted:', event.detail.mode);
|
|
276
|
-
});
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
Since **4.0.3**, ordinary external scripts load in document order before the
|
|
280
|
-
following inline scripts run. This fixes library-dependent initialization such
|
|
281
|
-
as DPlayer. The decrypt event waits for restored external scripts to load, fail,
|
|
282
|
-
or reach a **15-second per-script deadline**. Existing `onload` / `onerror`
|
|
283
|
-
handlers are preserved. A timeout does not cancel a script; it can execute later.
|
|
284
|
-
Explicit `async` scripts still load independently; restored `defer` scripts do
|
|
285
|
-
not recreate a document parsing phase. Inline `type="module"` scripts and
|
|
286
|
-
asynchronous work inside scripts retain native scheduling and are not guaranteed
|
|
287
|
-
to finish before the decrypt event. Use their own readiness signals when needed.
|
|
288
|
-
|
|
289
|
-
Try the [script-loading demo](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/script-order/)
|
|
290
|
-
(password `hello`) for both manual and cached-key decryption.
|
|
291
|
-
|
|
292
|
-
### Encrypt TOC
|
|
34
|
+
Set `POST_PASSWORD` in your build environment, then run `npx hexo clean && npx hexo generate && npx hexo server`. Open the post, type the passphrase and press **Enter**. Deploy the generated site over **HTTPS**. To protect multiple posts with one rule, use [tag-based encryption](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Tag-Based-Encryption).
|
|
293
35
|
|
|
294
|
-
**
|
|
295
|
-
plaintext retained for legacy Hexo integrations. Hiding a generated TOC with
|
|
296
|
-
`display:none` still exposes its headings. Search and feed integrations must also
|
|
297
|
-
exclude plaintext fields from encrypted posts.
|
|
36
|
+
**What stays public:** the title, the abstract, and any source Markdown or original media you publish separately. Keep private source out of public repositories. A visitor can download the ciphertext and try passwords offline; this is not a substitute for access-controlled hosting. [Security model →](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Security-Model)
|
|
298
37
|
|
|
299
|
-
|
|
38
|
+
## Choose a look
|
|
300
39
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
<% } %>
|
|
305
|
-
<%- post.content %>
|
|
306
|
-
```
|
|
40
|
+
| [Wave](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/wave/) | [Terminal](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/terminal/) |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| [](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/wave/) | [](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/terminal/) |
|
|
307
43
|
|
|
308
|
-
|
|
309
|
-
`hexo-blog-decrypt` callback, reading the revealed `#hexo-blog-encrypt` content
|
|
310
|
-
rather than publishing a hidden plaintext TOC.
|
|
44
|
+
Set `theme:` per post or site-wide. All 11 prompts use the same encryption; the eight classics keep their distinct focus and filled states.
|
|
311
45
|
|
|
312
|
-
|
|
313
|
-
If you want to disable the logging, you can add a silent property in `_config.yml` and set it to true.
|
|
46
|
+
**Classic:** [default](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/default/) · [blink](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/blink/) · [flip](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/flip/) · [shrink](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/shrink/) · [surge](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/surge/) · [up](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/up/) · [wave](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/wave/) · [xray](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/xray/)
|
|
314
47
|
|
|
315
|
-
|
|
316
|
-
# Security
|
|
317
|
-
encrypt: # hexo-blog-encrypt
|
|
318
|
-
silent: true
|
|
319
|
-
```
|
|
48
|
+
**Modern:** [minimal](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/minimal/) · [card](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/card/) · [terminal](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/terminal/)
|
|
320
49
|
|
|
321
|
-
|
|
50
|
+
## What to know before publishing
|
|
322
51
|
|
|
323
|
-
|
|
324
|
-
Previously, we use `template` to let users modify their own themes. Turn out that it's not a simple way. So, we are introducing this feature here.
|
|
52
|
+
Package **v4.2.0** writes format 5 and can still read format 4 posts. It uses scrypt and AES-256-GCM, with no runtime npm dependencies. Readers need HTTPS or localhost. Key caching is **off by default**; leave it off on shared devices.
|
|
325
53
|
|
|
326
|
-
|
|
54
|
+
<details>
|
|
55
|
+
<summary><strong>Passwords, saved keys and rebuilds</strong></summary>
|
|
327
56
|
|
|
328
|
-
|
|
57
|
+
| Front matter | Effect |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `password: { env: NAME }` | Read the password from the build environment. Also supported in `encrypt.tags[].password`. A missing or empty variable fails the build. |
|
|
60
|
+
| `password: ""` | Keep this post public even if a tag would otherwise encrypt it. |
|
|
329
61
|
|
|
330
|
-
|
|
331
|
-
---
|
|
332
|
-
title: Theme test
|
|
333
|
-
date: 2019-12-21 11:54:07
|
|
334
|
-
tags:
|
|
335
|
-
- A Tag should be encrypted
|
|
336
|
-
theme: xray
|
|
337
|
-
password: "hello"
|
|
338
|
-
---
|
|
339
|
-
```
|
|
62
|
+
`autoSave` stores a non-extractable CryptoKey in IndexedDB, not the password: format 5 uses an HKDF base key; format 4 uses an AES-GCM key. Upgrading purges legacy raw keys, so readers may need to enter their password once. Same-origin code can still use the saved key. A reader can choose **Forget saved key**; `window.hexoBlogEncrypt.forget(target?)` confirms deletion only when the storage transaction completes.
|
|
340
63
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
This would be a default one.
|
|
344
|
-
|
|
345
|
-
```yaml
|
|
346
|
-
# Security
|
|
347
|
-
encrypt: # hexo-blog-encrypt
|
|
348
|
-
abstract: Here's something encrypted, password is required to continue reading.
|
|
349
|
-
message: Hey, password is required here.
|
|
350
|
-
tags:
|
|
351
|
-
- {name: encryptAsDiary, password: passwordA}
|
|
352
|
-
- {name: encryptAsTips, password: passwordB}
|
|
353
|
-
theme: xray
|
|
354
|
-
wrong_pass_message: Oh, this is an invalid password. Check and try again, please.
|
|
355
|
-
# Deprecated under v4 (alias of `wrong_pass_message`); see "Advanced settings".
|
|
356
|
-
wrong_hash_message: Oh, these decrypted content cannot be verified, but you can still have a look.
|
|
357
|
-
|
|
358
|
-
```
|
|
64
|
+
`stableSalt` and `autoSave` default to false. On Cloudflare Pages, Vercel, Netlify or GitHub Actions, `stableSalt: true` can preserve that cache across clean builds. If the permalink changes, the old entry is invalidated. Each encryption still uses a random nonce. A commitment mismatch clears the entry; if AES-GCM authentication fails, the cache is cleared too.
|
|
359
65
|
|
|
360
|
-
|
|
66
|
+
</details>
|
|
361
67
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
+ [shrink](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/shrink/)
|
|
365
|
-
+ [flip](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/flip/)
|
|
366
|
-
+ [up](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/up/)
|
|
367
|
-
+ [surge](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/surge/)
|
|
368
|
-
+ [wave](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/wave/)
|
|
369
|
-
+ [xray](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/xray/)
|
|
68
|
+
<details>
|
|
69
|
+
<summary><strong>Encryption, asset integrity and theme integrations</strong></summary>
|
|
370
70
|
|
|
71
|
+
The default is `scrypt` (`N=32768, r=8, p=3`); alternatives are `pbkdf2-sha256` (600000 iterations) and `pbkdf2-sha512` (220000). HKDF-SHA256 separates encryption and commitment values per envelope. Older bundles cannot read new posts: deploy HTML together with `css/hbe.<hex10>.css` and `lib/hbe.<hex10>.js`. SHA-384 checks cover the emitted bytes, assuming trusted HTML.
|
|
371
72
|
|
|
372
|
-
|
|
73
|
+
Listen for `hexo-blog-decrypt` to rebuild a TOC or rerender MathJax. Never generate a TOC, feed or search index from private plaintext. The [encrypted TOC guide](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Encrypted-TOC) includes the `hexo-encrypt-toc` skill. Ordinary external scripts run in document order, with a 15-second wait per script; `async` scripts and inline `type="module"` keep their native scheduling. [Try the script-order demo](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/script-order/).
|
|
373
74
|
|
|
374
|
-
|
|
75
|
+
</details>
|
|
375
76
|
|
|
376
|
-
|
|
77
|
+
**[Browse the wiki](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki)** · [Configuration](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Configuration-Reference) · [Create a theme](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Theme-Authoring) · [Troubleshooting](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Troubleshooting)
|
|
377
78
|
|
|
378
|
-
|
|
79
|
+
[Contribute](https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/.github/CONTRIBUTING.md) · [Report a vulnerability privately](https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/SECURITY.md) · [MIT license](https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/LICENSE) · Thanks to [xiazeyu](https://github.com/xiazeyu).
|