Metadata-Version: 2.1
Name: rclone-crypt
Version: 1.0.0
Summary: Python implementation of encryption/decryption for rclone (crypt storage)
Home-page: https://github.com/Ftbom/rclone_crypt_py
Author: ftbom
Author-email: lz490070@gmail.com
License: MIT
Project-URL: Bug Tracker, https://github.com/Ftbom/rclone_crypt_py/issues
Keywords: rclone,decrypt,encrypt
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyNaCl
Requires-Dist: pycryptodome

# rclone_crypt_py

[简体中文](https://github.com/Ftbom/rclone_crypt_py/blob/main/README.md), [English](https://github.com/Ftbom/rclone_crypt_py/blob/main/README-en.md)

python实现的针对rclone(crypt storage)的加密/解密

## 使用

```python
from rclone import Crypt
# 初始化
# 分别传入passwd1和passwd2

# 此处的passwd是创建crypt时的密码，而不是rclone配置文件中的密码
# 若未设置passwd2，可省略第二个参数
crypt = Crypt('PvrhK9lOaJMdJO2', 'bjnW66SNkUuV4hX')

# 若直接传入rclone配置文件中的密码（混淆后的密码），需将passwd_obscured参数设为True
# crypt = Crypt('SpnX0yEFxpNJjo9bxd3xAlVoXA7F4cr3C0SA-zmfzw', 'ziWH7jKYerB6o5vHnaXAvISTguFD6ZFJFbhT3BlLVQ', True)

# 文件加密/解密
crypt.File.file_decrypt(input_file_path, output_file_path)
crypt.File.file_encrypt(input_file_path, output_file_path)

# 文件路径加密/解密
# obfuscate
crypt.Name.obfuscate_encrypt('Hello,Word')
crypt.Name.obfuscate_decrypt('188.Nkrru,cuxj')

#standard
crypt.Name.standard_encrypt('Hello,Word/你好，世界')
crypt.Name.standard_decrypt('tj0ivgsmd9vh4ccfov7f739in0/lb8g1ak1849smj6mlmpv2c5aio')
```

```python
# bytes解密
from rclone import Crypt
crypt = Crypt('PvrhK9lOaJMdJO2', 'bjnW66SNkUuV4hX')

with open('D:/Download/test.bin', 'rb') as f:
    f.seek(8) # 跳过固定文件头 b'RCLONE\x00\x00'
    init_nonce = f.read(24) # 读取nonce
    f.seek(5 * (1024 * 64 + 16), 1) # 跳过5个数据块
    input_bytes = f.read(10 * (1024 * 64 + 16)) # 读取10个数据块
    output_bytes = crypt.File.bytes_decrypt(input_bytes, init_nonce, 5) # 数据块解密
```
