大家好,今天给大家分享一个静态页面加密工具StatiCrypt,旨在为用户提供一种便捷的方式来加密静态HTML页面,以增强其内容的安全性。

项目介绍

StatiCrypt采用AES-256对称加密算法,这种算法以高安全性著称,广泛应用于各种加密场景中。通过StatiCrypt加密后的HTML页面,只有在用户输入正确的密码后才能访问,从而有效地保护了页面内容的隐私性。

功能特点

纯前端加密:StatiCrypt完全在前端实现加密和解密功能,无需依赖后端服务。这使得它在使用上更加灵活和便捷,用户只需在本地即可完成加密和解密操作。

AES-256加密:项目采用AES-256加密算法,确保了加密后的数据具有极高的安全性。即使攻击者获取了加密后的源码,也无法轻易还原出原始的HTML内容。

密码保护:用户可以为自己的静态HTML页面设置一个密码,只有输入正确的密码才能访问页面内容。这为用户提供了一种简单而有效的访问控制手段。

易于使用:StatiCrypt提供了简洁明了的用户界面和操作流程,用户只需几步操作即可完成加密和解密过程。同时,项目还提供了详细的文档和示例代码,帮助用户更好地理解和使用该项目。

应用场景

StatiCrypt适用于各种需要保护静态HTML页面内容的场景,如:

1.个人博客或网站

用户可以使用StatiCrypt来加密自己的个人博客或网站中的敏感信息,如个人信息、联系方式等,以防止未经授权的访问和泄露。

2.企业内网

在企业内网中,可以使用StatiCrypt来加密一些内部文档或页面,以确保只有具有相应权限的员工才能访问这些内容。

3.教育或培训材料

教育机构或培训师可以使用StatiCrypt来加密一些重要的教育或培训材料,以确保学员在未经授权的情况下无法获取或传播这些材料。

安装使用

安装

Staticrypt可通过npm作为CLI使用,使用npm安装:

npm install staticrypt

安装后您可以使用npx staticrypt运行它……

您也可以使用npm install -g staticrypt进行全局安装,然后从任何地方调用staticrypt…。

使用

1.加密单个html文件

加密test.html并创建一个加密的/test.html文件(使用-d my_directory更改输出目录):

# 如果环境变量STATICRYPT_PASSWORD中未配置,则会在下一步提示输入密码,输入的密码不会保留在您的终端命令历史记录中

staticrypt test.html

# 您还可以将密码作为参数传递
staticrypt test.html -p <long-password>

2.加密多个html文件

加密结果将会输出到指定的结果目录,非 HTML 文件将按原样从输入目录中复制,因此您可以根据需要轻松用加密目录覆盖它。

# this will encrypt test_A.html and test_B.html
staticrypt test_A.html test_B.html
# => encrypted files are in encrypted/test_A.html and encrypted/test_B.html

# you can also use the -r flag to recursively encrypt all files in a directory
staticrypt dir_to_encrypt -r
# => encrypted files are in encrypted/dir_to_encrypt/...

# if you don't want to include the directory name in the output path, you can use 
# `dir_to_encrypt/*` instead. `-r` will include potential subdirectories as well
staticrypt dir_to_encrypt/* -r
# => encrypted files are in encrypted/...

3.获取可共享的自动解密链接

该链接包含散列密码,将自动解密文件 - 您可以包含文件 URL 或留空。(⚠️加密后需要保留您的.staticrypt.json,以便每次加密时盐都是相同的,否则重新加密将使链接无效):

# you can also pass '--share' without specifying the URL to get the `#staticrypt_pwd=...` 
staticrypt test.html --share https://example.com/encrypted.html
# => https://example.com/encrypted.html#staticrypt_pwd=5bfbf1343c7257cd7be23ecd74bb37fa2c76d041042654f358b6255baeab898f

# add --share-remember to auto-enable "Remember-me" - useful if you want send one link to 
# autodecrypt multiple pages (you can also just append '&remember_me')
staticrypt test.html --share --share-remember
# => #staticrypt_pwd=5bfbf1343c7257cd7be23ecd74bb37fa2c76d041042654f358b6255baeab898f&remember_me

4.自定义密码提示页面

可自定义 HTML 以使加密页面符合您的网站风格。

# use your own custom template
staticrypt test.html -t my/own/password_template.html

# or customize the default template
staticrypt test.html \
    --template-color-primary "#fd45a4" \
    --template-title "My custom title" \
    --template-instructions "To unlock this file, you should..." \
    # ...

更多使用命令、参数可使用staticrypt --help查看。

项目地址

https://github.com/robinmoisson/staticrypt