hexo-blog-encrypt 4.1.0 → 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 +43 -338
- package/ReadMe.zh.md +43 -317
- package/lib/hbe.blink.html +9 -8
- 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 +9 -8
- package/lib/hbe.flip.html +9 -8
- package/lib/hbe.minimal.html +24 -0
- package/lib/hbe.shrink.html +8 -8
- package/lib/hbe.style.css +549 -849
- package/lib/hbe.surge.html +14 -11
- package/lib/hbe.terminal.html +24 -0
- package/lib/hbe.up.html +9 -8
- package/lib/hbe.wave.html +13 -11
- package/lib/hbe.xray.html +14 -12
- package/package.json +9 -2
- package/src/server/config.js +46 -24
- package/src/server/crypto.js +49 -57
- package/src/server/format.js +77 -0
- package/src/server/generator.js +26 -65
- package/src/server/index.js +9 -11
package/ReadMe.md
CHANGED
|
@@ -1,374 +1,79 @@
|
|
|
1
1
|
# hexo-blog-encrypt
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> with AES-256-GCM and decrypted in the reader's browser with the Web Crypto
|
|
5
|
-
> API. No server, no plaintext in the generated HTML.
|
|
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.
|
|
6
4
|
|
|
7
|
-
**[
|
|
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)
|
|
8
6
|
|
|
9
|
-
[](https://www.npmjs.com/package/hexo-blog-encrypt)
|
|
11
|
-
[](https://www.npmjs.com/package/hexo-blog-encrypt)
|
|
12
|
-
[](./LICENSE)
|
|
13
|
-
[](https://github.com/D0n9X1n/hexo-blog-encrypt/actions/workflows/test.yml)
|
|
14
|
-
[](./docs/DEVELOPMENT.md)
|
|
15
|
-
[](https://d0n9x1n.github.io/hexo-blog-encrypt/)
|
|
16
|
-
[](./package.json)
|
|
17
|
-
[](https://hexo.io/)
|
|
18
|
-
[](./package.json)
|
|
19
|
-
[](https://www.npmjs.com/package/hexo-blog-encrypt#provenance)
|
|
20
|
-
[](https://github.com/D0n9X1n/hexo-blog-encrypt/stargazers)
|
|
21
|
-
|
|
22
|
-
English · [中文说明](./ReadMe.zh.md) · [Wiki](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki) · [Releases](https://github.com/D0n9X1n/hexo-blog-encrypt/releases)
|
|
23
|
-
|
|
24
|
-
## Contents
|
|
25
|
-
|
|
26
|
-
- [Highlights](#highlights)
|
|
27
|
-
- [Live demo](#live-demo)
|
|
28
|
-
- [Install](#install)
|
|
29
|
-
- [Quick start](#quick-start)
|
|
30
|
-
- [Configuration](#configuration)
|
|
31
|
-
- [Theme integration](#theme-integration)
|
|
32
|
-
- [Browser support](#browser-support)
|
|
33
|
-
- [Why upgrade from v3?](#why-upgrade-from-v3)
|
|
34
|
-
- [Upgrading from v3](#upgrading-from-v3)
|
|
35
|
-
- [Contributing](#contributing)
|
|
36
|
-
- [License](#license)
|
|
37
|
-
|
|
38
|
-
## Highlights
|
|
7
|
+
[](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/card/)
|
|
39
8
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
| **Front-matter or tag passwords** | Set `password:` on a post, or map tags to passwords in `_config.yml`. |
|
|
46
|
-
| **Eight themes** | `default`, `blink`, `flip`, `shrink`, `surge`, `up`, `wave`, `xray`. Add your own by dropping in one HTML file. |
|
|
47
|
-
| **Scripts keep working** | Scripts inside a decrypted post run in document order. A `hexo-blog-decrypt` event fires when the post is revealed. |
|
|
48
|
-
| **Privacy by default** | Passwords and keys are not stored unless you opt in with `autoSave`. |
|
|
49
|
-
| **Tested** | 100% server line, branch and function coverage, plus Playwright end-to-end tests across every theme. |
|
|
50
|
-
|
|
51
|
-
## Live demo
|
|
52
|
-
|
|
53
|
-
Open the **[demo site](https://d0n9x1n.github.io/hexo-blog-encrypt/)**. All passwords are `hello`.
|
|
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/)
|
|
54
14
|
|
|
55
|
-
|
|
56
|
-
- [Decrypt callback](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/callback/)
|
|
57
|
-
- [Script loading order and cached keys](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/script-order/)
|
|
15
|
+
## Lock your first post
|
|
58
16
|
|
|
59
|
-
|
|
17
|
+
From your Hexo site directory (Node.js 18+, Hexo 5+):
|
|
60
18
|
|
|
61
|
-
```
|
|
19
|
+
```sh
|
|
62
20
|
npm install --save hexo-blog-encrypt
|
|
63
21
|
```
|
|
64
22
|
|
|
65
|
-
|
|
66
|
-
npm with [provenance](https://docs.npmjs.com/generating-provenance-statements)
|
|
67
|
-
and mirrored to GitHub Packages as `@d0n9x1n/hexo-blog-encrypt`.
|
|
68
|
-
|
|
69
|
-
## Quick start
|
|
70
|
-
|
|
71
|
-
Add a `password` to a post's front matter:
|
|
72
|
-
|
|
73
|
-
```markdown
|
|
74
|
-
---
|
|
75
|
-
title: Hello World
|
|
76
|
-
date: 2016-03-30 21:18:02
|
|
77
|
-
password: hello
|
|
78
|
-
---
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Then rebuild and preview:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
hexo clean && hexo generate && hexo server
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
The post body is replaced by a password form. Index pages show the `abstract`
|
|
88
|
-
text instead of the content.
|
|
89
|
-
|
|
90
|
-
## Configuration
|
|
91
|
-
|
|
92
|
-
Settings are resolved in this order:
|
|
93
|
-
|
|
94
|
-
**post front matter > `_config.yml` `encrypt:` block > built-in defaults**
|
|
95
|
-
|
|
96
|
-
A front-matter `password` takes precedence over a tag password.
|
|
97
|
-
|
|
98
|
-
### Front matter
|
|
99
|
-
|
|
100
|
-
```markdown
|
|
101
|
-
---
|
|
102
|
-
title: Hello World
|
|
103
|
-
tags:
|
|
104
|
-
- encryptAsDiary
|
|
105
|
-
date: 2016-03-30 21:12:21
|
|
106
|
-
password: mikemessi
|
|
107
|
-
abstract: Here's something encrypted, password is required to continue reading.
|
|
108
|
-
message: Hey, password is required here.
|
|
109
|
-
wrong_pass_message: Oh, this is an invalid password. Check and try again, please.
|
|
110
|
-
theme: xray
|
|
111
|
-
---
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Site-wide `_config.yml`
|
|
23
|
+
Add a password to the front matter of **one** post. Use a long, unique passphrase instead of the demo password.
|
|
115
24
|
|
|
116
25
|
```yaml
|
|
117
|
-
encrypt: # hexo-blog-encrypt
|
|
118
|
-
abstract: Here's something encrypted, password is required to continue reading.
|
|
119
|
-
message: Hey, password is required here.
|
|
120
|
-
wrong_pass_message: Oh, this is an invalid password. Check and try again, please.
|
|
121
|
-
theme: default
|
|
122
|
-
silent: false
|
|
123
|
-
|
|
124
|
-
# Encrypt every post that carries one of these tags.
|
|
125
|
-
tags:
|
|
126
|
-
- {name: encryptAsDiary, password: passwordA}
|
|
127
|
-
- {name: encryptAsTips, password: passwordB}
|
|
128
|
-
|
|
129
|
-
# Show a visible "Decrypt" button next to the password field.
|
|
130
|
-
# Default: true.
|
|
131
|
-
decryptButton:
|
|
132
|
-
show: true
|
|
133
|
-
text: Decrypt
|
|
134
|
-
|
|
135
|
-
# Cache the derived AES key in localStorage so reloads skip the password
|
|
136
|
-
# prompt. Default: false. Enable globally here or per post in front matter.
|
|
137
|
-
# Entries are stored under `hbe.v4.<page path>`.
|
|
138
|
-
autoSave: false
|
|
139
|
-
|
|
140
|
-
# Keep the PBKDF2 salt stable across clean builds for the same post
|
|
141
|
-
# permalink. Default: false. Useful with autoSave on Cloudflare Pages,
|
|
142
|
-
# Vercel, Netlify, GitHub Actions, and other platforms that rebuild
|
|
143
|
-
# generated HTML from a clean environment on every deploy.
|
|
144
|
-
#
|
|
145
|
-
# Only the salt is stable. The AES-GCM nonce stays random for every
|
|
146
|
-
# encryption to avoid nonce reuse. If the post permalink changes, the
|
|
147
|
-
# stable salt changes too, and the page's existing localStorage cache is
|
|
148
|
-
# invalidated.
|
|
149
|
-
stableSalt: false
|
|
150
|
-
|
|
151
|
-
# PBKDF2 iteration count. Floor: 100_000. Recommended: 600_000 or more
|
|
152
|
-
# (OWASP 2023 for PBKDF2-SHA256). Values below the recommendation log a
|
|
153
|
-
# build warning. Default: 250_000.
|
|
154
|
-
kdf:
|
|
155
|
-
iterations: 250000
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
When `autoSave` reads a cached key, it compares the cached salt with the
|
|
159
|
-
current page salt. A nonce change alone does not delete the cache up front;
|
|
160
|
-
the browser tries the cached key with the current page nonce and ciphertext.
|
|
161
|
-
If AES-GCM authentication fails, the cache entry is cleared and the visitor is
|
|
162
|
-
asked for the password again.
|
|
163
|
-
|
|
164
|
-
**Saved keys and their exposure.** A saved key lives in `localStorage` under
|
|
165
|
-
`hbe.v4.<page path>` and unlocks that post on this device until it is removed.
|
|
166
|
-
Any script running on the same origin (your theme, analytics, comment
|
|
167
|
-
widgets, or an injected script) can read it, so enable `autoSave` only when
|
|
168
|
-
you trust every script on the site. After a post is revealed with a saved
|
|
169
|
-
key, a **Forget saved key** button above it deletes the entry. Turning
|
|
170
|
-
`autoSave` off for a post deletes that post's saved key on the next visit,
|
|
171
|
-
and leftover v3 `hexo-blog-encrypt:#…` entries are removed automatically.
|
|
172
|
-
|
|
173
|
-
### Option reference
|
|
174
|
-
|
|
175
|
-
| Option | Default | Description |
|
|
176
|
-
| --- | --- | --- |
|
|
177
|
-
| `password` | none | Encrypts the post. `""` disables encryption, including tag encryption. A matching tag entry without a password fails the build. |
|
|
178
|
-
| `password: { env: NAME }` | none | Reads the password from environment variable `NAME` at build time (front matter, `encrypt.password` or `encrypt.tags[].password`). A missing or empty variable fails the build; the value is never logged or rendered. This keeps passwords out of config files, not out of plaintext Markdown you commit publicly. |
|
|
179
|
-
| `abstract` | `Here's something encrypted…` | Excerpt shown on index and archive pages. |
|
|
180
|
-
| `message` | `Hey, password is required here.` | Label of the password field. |
|
|
181
|
-
| `wrong_pass_message` | `Oh, this is an invalid password…` | Inline error after a failed attempt. |
|
|
182
|
-
| `theme` | `default` | One of the eight bundled themes. Unknown names fall back to `default` with a warning. |
|
|
183
|
-
| `tags` | `[]` | `_config.yml` only. `{name, password}` pairs for tag encryption. |
|
|
184
|
-
| `decryptButton.show` / `.text` | `true` / `Decrypt` | Visible submit button and its label. |
|
|
185
|
-
| `autoSave` | `false` | Cache the derived key in `localStorage`. |
|
|
186
|
-
| `stableSalt` | `false` | Derive the salt from the permalink so cached keys survive clean rebuilds. |
|
|
187
|
-
| `kdf.iterations` | `250000` | PBKDF2 iterations. Must be an integer of at least 100,000. |
|
|
188
|
-
| `silent` | `false` | Suppress build-time info logs. Warnings and errors still print. |
|
|
189
|
-
| `wrong_hash_message` | `wrong_pass_message` | Deprecated alias. AES-GCM reports wrong passwords and tampering the same way. |
|
|
190
|
-
| `template` | none | Deprecated alias of `theme`. |
|
|
191
|
-
|
|
192
|
-
Boolean options (`autoSave`, `stableSalt`, `silent`, `decryptButton.show`) must be `true` or `false`. Quoted `"true"`/`"false"` are accepted with a warning; any other value fails the build.
|
|
193
|
-
|
|
194
|
-
The default `abstract`, `message`, `wrong_pass_message` and `decryptButton.text` follow the post's `lang`/`language`, else the site `language`. `zh`, `zh-CN` and `zh-Hans` use Simplified Chinese; everything else uses English. Explicit values always win.
|
|
195
|
-
|
|
196
|
-
### Disable tag encryption for one post
|
|
197
|
-
|
|
198
|
-
Set an empty password in that post's front matter:
|
|
199
|
-
|
|
200
|
-
```markdown
|
|
201
26
|
---
|
|
202
|
-
title:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
27
|
+
title: Field notes
|
|
28
|
+
theme: wave
|
|
29
|
+
password: { env: POST_PASSWORD }
|
|
30
|
+
abstract: Notes from the trip. Ask me for the password.
|
|
206
31
|
---
|
|
207
32
|
```
|
|
208
33
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
### After-decrypt event
|
|
212
|
-
|
|
213
|
-
The plugin dispatches `hexo-blog-decrypt` once on `window` after each post is
|
|
214
|
-
revealed. `event.detail.mode` is `manual` (password entered) or `cached`
|
|
215
|
-
(saved key), and `event.detail.element` is the revealed container (useful when
|
|
216
|
-
an index page shows several encrypted posts). Listen for it to re-run anything
|
|
217
|
-
that scans the post body:
|
|
218
|
-
|
|
219
|
-
```js
|
|
220
|
-
window.addEventListener('hexo-blog-decrypt', function (event) {
|
|
221
|
-
// Reinitialize your theme's table of contents, syntax highlighting, etc.
|
|
222
|
-
console.log('Decrypted:', event.detail.mode, event.detail.element);
|
|
223
|
-
});
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### PJAX and SPA themes
|
|
227
|
-
|
|
228
|
-
The bundle initializes every encrypted post on the page once. It re-scans
|
|
229
|
-
automatically on `pjax:complete`, `pjax:success`, `swup:contentReplaced` and
|
|
230
|
-
`turbo:load` (dispatched on `document`). For other routers, call the idempotent
|
|
231
|
-
initializer after swapping content:
|
|
232
|
-
|
|
233
|
-
```js
|
|
234
|
-
window.hexoBlogEncrypt.init(); // whole document
|
|
235
|
-
window.hexoBlogEncrypt.init(container); // only a subtree
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Scripts inside encrypted posts
|
|
239
|
-
|
|
240
|
-
Scripts in a post run after it is decrypted. Since **4.0.3**, ordinary external
|
|
241
|
-
scripts load in document order before later inline scripts run, so
|
|
242
|
-
library-dependent code such as DPlayer initializes correctly. The decrypt event
|
|
243
|
-
waits until restored external scripts load, fail, or reach a **15-second
|
|
244
|
-
per-script deadline**. A timeout does not cancel a script; it can still execute
|
|
245
|
-
later. Existing `onload` and `onerror` handlers are preserved. Explicit `async`
|
|
246
|
-
scripts still load independently, and restored `defer` scripts do not recreate a
|
|
247
|
-
document parsing phase. Inline `type="module"` scripts and asynchronous work
|
|
248
|
-
inside scripts keep native scheduling and may finish after the decrypt event.
|
|
249
|
-
|
|
250
|
-
```markdown
|
|
251
|
-
<script>
|
|
252
|
-
// Runs after this post is decrypted.
|
|
253
|
-
console.log('Hello from an encrypted post');
|
|
254
|
-
</script>
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
### Table of contents
|
|
258
|
-
|
|
259
|
-
**Never render an encrypted post's `post.origin` into generated HTML.** It
|
|
260
|
-
holds plaintext for legacy Hexo integrations. A TOC hidden with
|
|
261
|
-
`display:none` still publishes its headings. Search, feed and sitemap
|
|
262
|
-
integrations must also exclude plaintext fields from encrypted posts.
|
|
263
|
-
|
|
264
|
-
Render a server-side TOC only for unencrypted posts:
|
|
265
|
-
|
|
266
|
-
```ejs
|
|
267
|
-
<% if (post.toc === true && !post.encrypt) { %>
|
|
268
|
-
<div class="toc-article"><%- toc(post.content, {list_number: true}) %></div>
|
|
269
|
-
<% } %>
|
|
270
|
-
<%- post.content %>
|
|
271
|
-
```
|
|
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).
|
|
272
35
|
|
|
273
|
-
|
|
274
|
-
`hexo-blog-decrypt` handler from the revealed `#hexo-blog-encrypt` content.
|
|
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)
|
|
275
37
|
|
|
276
|
-
|
|
38
|
+
## Choose a look
|
|
277
39
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
[default](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/default/) ·
|
|
282
|
-
[blink](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/blink/) ·
|
|
283
|
-
[flip](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/flip/) ·
|
|
284
|
-
[shrink](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/shrink/) ·
|
|
285
|
-
[surge](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/surge/) ·
|
|
286
|
-
[up](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/up/) ·
|
|
287
|
-
[wave](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/wave/) ·
|
|
288
|
-
[xray](https://d0n9x1n.github.io/hexo-blog-encrypt/demo/theme/xray/)
|
|
289
|
-
|
|
290
|
-
To add a theme, see [docs/THEMES.md](./docs/THEMES.md).
|
|
291
|
-
|
|
292
|
-
## Browser support
|
|
293
|
-
|
|
294
|
-
Decryption uses Web Crypto (`crypto.subtle`), which requires a **secure
|
|
295
|
-
context**: HTTPS or `http://localhost`.
|
|
296
|
-
|
|
297
|
-
| Browser | Minimum | Tested |
|
|
298
|
-
| --- | --- | --- |
|
|
299
|
-
| Chromium / Edge | 92+ | Automated: Playwright Chromium in CI, Hexo 7 and 8 |
|
|
300
|
-
| Firefox | 90+ | Automated: Playwright Firefox in CI |
|
|
301
|
-
| Safari (macOS) | 14+ | Automated: Playwright WebKit in CI (WebKit engine, not Safari itself) |
|
|
302
|
-
| Safari (iOS) | 14+ | Manual only |
|
|
303
|
-
|
|
304
|
-
Minimum versions come from Web Crypto and language feature support; CI runs
|
|
305
|
-
the current Playwright builds, not these minimums.
|
|
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/) |
|
|
306
43
|
|
|
307
|
-
|
|
308
|
-
decryption cannot run; the post shows an "open this page over HTTPS" message
|
|
309
|
-
instead of the wrong-password error. Always serve production sites over HTTPS.
|
|
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.
|
|
310
45
|
|
|
311
|
-
|
|
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/)
|
|
312
47
|
|
|
313
|
-
|
|
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/)
|
|
314
49
|
|
|
315
|
-
|
|
316
|
-
replaces v3's AES-CBC plus a separate HMAC: one primitive, one
|
|
317
|
-
authentication path, and no CBC padding-oracle or HMAC-comparison bugs.
|
|
318
|
-
- **Per-post salt and nonce.** v3 used the same salt for every post, so one
|
|
319
|
-
password derived the same key everywhere. v4 derives an independent key per
|
|
320
|
-
post, so an attacker cannot reuse PBKDF2 work across posts that share a
|
|
321
|
-
password.
|
|
322
|
-
- **Stronger KDF defaults.** v3 used **1,024** PBKDF2-SHA256 iterations. v4
|
|
323
|
-
defaults to **250,000** (about 240 times more work per guess) and recommends
|
|
324
|
-
600,000 or more (OWASP 2023). Tune it per post with `kdf.iterations`.
|
|
325
|
-
- **Privacy by default.** v3 always cached decrypted posts in `localStorage`,
|
|
326
|
-
so anyone with later access to the device could read them again. v4 defaults
|
|
327
|
-
to `autoSave: false`; you opt in per post or globally.
|
|
328
|
-
- **Inline errors.** v3 showed a `window.alert()` dialog on a wrong password.
|
|
329
|
-
v4 shows the error next to the field (`role="alert"`).
|
|
330
|
-
- **Optional decrypt button** for readers who don't know Enter submits the form.
|
|
331
|
-
- **Smaller bundle.** CryptoJS is gone; the browser bundle is about 6 KB
|
|
332
|
-
minified.
|
|
333
|
-
- **Tested.** 100% server coverage plus Playwright tests across all eight
|
|
334
|
-
themes, on every push.
|
|
50
|
+
## What to know before publishing
|
|
335
51
|
|
|
336
|
-
|
|
337
|
-
[Migration v3 → v4](https://github.com/D0n9X1n/hexo-blog-encrypt/wiki/Migration-v3-to-v4).
|
|
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.
|
|
338
53
|
|
|
339
|
-
|
|
54
|
+
<details>
|
|
55
|
+
<summary><strong>Passwords, saved keys and rebuilds</strong></summary>
|
|
340
56
|
|
|
341
|
-
|
|
342
|
-
|
|
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. |
|
|
343
61
|
|
|
344
|
-
|
|
345
|
-
2. Rebuild from source: `hexo clean && hexo generate`.
|
|
346
|
-
3. Purge your CDN if you use one. Post HTML changes on every build because each
|
|
347
|
-
encryption uses a fresh nonce. The runtime asset `lib/hbe.<hash>.js` is
|
|
348
|
-
content-hashed and changes only when the bundle changes.
|
|
349
|
-
4. Optional: remove `wrong_hash_message` from your config and front matter. It
|
|
350
|
-
is deprecated in v4 and will be removed in v5.
|
|
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.
|
|
351
63
|
|
|
352
|
-
|
|
353
|
-
[v4.0.0 release notes](https://github.com/D0n9X1n/hexo-blog-encrypt/releases/tag/v4.0.0)
|
|
354
|
-
and [Releases](https://github.com/D0n9X1n/hexo-blog-encrypt/releases) for the
|
|
355
|
-
full list of breaking changes.
|
|
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.
|
|
356
65
|
|
|
357
|
-
|
|
66
|
+
</details>
|
|
358
67
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
logs and your configuration when reporting a bug.
|
|
68
|
+
<details>
|
|
69
|
+
<summary><strong>Encryption, asset integrity and theme integrations</strong></summary>
|
|
362
70
|
|
|
363
|
-
-
|
|
364
|
-
- [Development](./docs/DEVELOPMENT.md)
|
|
365
|
-
- [Releasing](./docs/RELEASING.md)
|
|
366
|
-
- [Themes](./docs/THEMES.md)
|
|
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.
|
|
367
72
|
|
|
368
|
-
|
|
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/).
|
|
369
74
|
|
|
370
|
-
|
|
75
|
+
</details>
|
|
371
76
|
|
|
372
|
-
|
|
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)
|
|
373
78
|
|
|
374
|
-
|
|
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).
|