Encryption

Mr.Hope ... 2020-1-29 Feature
  • Encrypt
  • Feature
Less than 1 minute

The theme supports encryption of specific folders or specific paths, as well as global scope encryption.

Warning

Note that because of the limitation of vuepress, the content of the article is only hidden before being decrypted, and visitors can still get the content of the article from the source code (from js).

Please DO NOT USE this encryption function for any sensitive and confidential articles and files, please bear the consequences of it.

You can configure encryption options through the config field in themeConfig.encrypt.




 
 
 
 
 
 




module.exports = {
  themeConfig: {
    encrypt: {
      config: {
        // This will encrypt the entire guide directory, and both passwords are available
        "/guide/": ["1234", "5678"],
        // This will only encrypt config/page.html
        "/config/page.html": "1234",
      },
    },
  },
};
1
2
3
4
5
6
7
8
9
10
11
12

Tips

We recommend you to use encryption in this way, because the password will be hashed and salted by theme and will not appear in the output code.

# Temporary encryption

You can configure the password in the frontmatter of the page more conveniently.

---
password: abc1234
---
1
2
3

Warning

Though this is convinient , users can find the raw password through the source code.

Note

Since you can only input strings, all passwords should be strings. Please do not try to set other values!

# Global encryption

In some cases, you may want to encrypt the entire site, you can set themeConfig.encrypt.status to global to achieve it.

For global encryption, you can set one or more passwords in the format of string or string array in themeConfig.encrypt.global.

Tips

The consideration of multiple passwords is separation of permissions。 This allow you to depreacte or update some of the global passwords in future deployments, so that some users with certain password will lose access.

:::

Last update: January 21, 2022 16:43
Contributors: Mr.Hope