FernetCrypt CLI 使用密码加密和解密文件。
项目描述
FernetCrypt
一个命令行工具,实现了Fernet加密。
FernetCrypt加密是一个Python库,用于使用密码加密数据时的最佳实践。
Fernet结合了AES、PKCS7、HMAC和SHA256来执行重计算。
此工具包括一个“原始”模式,它只写入原始盐和加密数据,或者一个正常模式,它以base85格式存储盐并包含文件标识魔术字符串“#UF1#”。在任一情况下,数据以40,960字节为单位进行分块,以便加密比内存更大的文件。
用法
Usage: fernetcrypt [OPTIONS] COMMAND [ARGS]...
Encrypt or decrypt a file based on a password.
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. │
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ decrypt Decrypt a file. │
│ edit Edit an encrypted file in place. │
│ encrypt Encrypt a file. │
╰──────────────────────────────────────────────────────────────────────────────╯
Fernet is an encryption that uses existing tools (AES, PKCS7, HMAC, SHA256) to
implement a 'best practices' for encrypting a file with a password. It's
primary benefit is that it is easily availabile for Python programs, simple,
and secure. See for more information:
https://github.com/linsomniac/fernetcrypt
Usage: fernetcrypt encrypt [OPTIONS] INPUT_FILE [OUTPUT_FILE]
Encrypt a file.
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│ * input_file TEXT Input file to encrypt [default: None] │
│ [required] │
│ output_file [OUTPUT_FILE] Output file for the encrypted data │
│ [default: None] │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --password TEXT Password for encryption. Can also be │
│ specified in the 'FERNET_PASSWORD' │
│ environment variable. Otherwise, it will be │
│ read from the terminal. │
│ [env var: FERNET_PASSWORD] │
│ [default: None] │
│ --raw --no-raw Use 'raw' Fernet encrypted format rather │
│ than the default. │
│ [default: no-raw] │
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
Usage: fernetcrypt decrypt [OPTIONS] INPUT_FILE [OUTPUT_FILE]
Decrypt a file.
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│ * input_file TEXT Input file to decrypt [default: None] │
│ [required] │
│ output_file [OUTPUT_FILE] Output file for the plain-text data │
│ [default: None] │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --password TEXT Password for decryption. Can also be │
│ specified in the 'FERNET_PASSWORD' │
│ environment variable. Otherwise, it will be │
│ read from the terminal. │
│ [env var: FERNET_PASSWORD] │
│ [default: None] │
│ --raw --no-raw Use 'raw' Fernet encrypted format rather │
│ than the default. │
│ [default: no-raw] │
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
Usage: fernetcrypt edit [OPTIONS] FILENAME
Edit an encrypted file in place.
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│ * filename TEXT Encrypted file to edit [default: None] [required] │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --password TEXT Password for decryption. Can also be │
│ specified in the 'FERNET_PASSWORD' │
│ environment variable. Otherwise, it will be │
│ read from the terminal. │
│ [env var: FERNET_PASSWORD] │
│ [default: None] │
│ --raw --no-raw Use 'raw' Fernet encrypted format rather │
│ than the default. │
│ [default: no-raw] │
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
格式
此工具写入Fernet数据的标准格式如下
- 20字节base85编码的盐。
- 5字节的魔术数字:“#UF1#”
- 54712字节的Fernet加密数据块。最后一个块将小于此长度。
我将此格式称为“uPlaybook Fernet”,因为我为uPlaybook项目构建了它,并且似乎没有Fernet加密持久化的任何格式。
我选择此格式,因为基础Fernet加密数据似乎以ASCII编码,所以让盐也以ASCII编码,我想在其中放置一个魔术数字以识别文件,并允许文件版本,以防将来需要格式转换。
块大小选择为40,960字节,这是输入块的加密大小。这比4096字节略节省空间,但在2023年即使是小型机器也能很好地处理。加密数据以54,712字节的块形式存在(这是40,960字节加密后的结果)。
我将此称为“uPlaybook Fernet格式1”。
格式(原始)
如果提供了“--raw”选项,文件格式为
- 16字节盐(预期为非ASCII)。
- 54712字节的Fernet加密数据块。最后一个块将小于此长度。
这是,就我理解而言,Fernet加密数据的最基本格式,并放弃了我的魔数,因此可能可以读取不了解我上述格式的其他人的文件。假设他们选择了40K块大小,或者他们的加密数据小于40K。
这也可以被认为是“uPlaybook格式0”,这是在我决定添加魔数之前uPlaybook使用的格式。
许可证
CC0 1.0通用,更多信息请参阅LICENSE文件。
关闭
fernetcrypt-1.0.3.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c5c05c174466883ae4c705eca72f842b5d8b98f2206e9fcf16aebf98c7ae6649 |
|
MD5 | 0d943a4d9ec1d555a9500d5ef5b99426 |
|
BLAKE2b-256 | 80249c1aa34a959e7028d242eb2f3fdc1e810ccdc2e653f38564496d4645fb84 |
关闭
fernetcrypt-1.0.3-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6245a52a4262ed7a50fd188e570ca696979e90d21dcd0939b7f4edb08ba6458e |
|
MD5 | 54a0bd7077e30b8ae8436184f9d0f1ac |
|
BLAKE2b-256 | fa8786b09701592ea3dbbf948a13e847f25527e34b97980dd5833078504e86d9 |