instances/xiaodazi/skills/local-file-encrypt/SKILL.md
Encrypt and decrypt local files using strong encryption. Protect sensitive documents with password-based AES-256 encryption, all processed locally.
npx skillsauth add malue-ai/dazee-small local-file-encryptInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
帮助用户加密和解密本地文件:使用 AES-256 强加密保护敏感文档,全程本地处理。
首次使用时自动安装:
pip install cryptography
通过 Python 使用 cryptography 库实现 AES-256 加密。
import os
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
import base64
def derive_key(password: str, salt: bytes) -> bytes:
"""From password derive encryption key."""
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
iterations=480000,
)
return base64.urlsafe_b64encode(kdf.derive(password.encode()))
def encrypt_file(input_path: str, output_path: str, password: str):
"""Encrypt a file with password."""
salt = os.urandom(16)
key = derive_key(password, salt)
f = Fernet(key)
with open(input_path, 'rb') as file:
data = file.read()
encrypted = f.encrypt(data)
with open(output_path, 'wb') as file:
file.write(salt + encrypted) # salt prepended
print(f"Encrypted: {output_path} ({len(data)} -> {len(encrypted)+16} bytes)")
# Usage
encrypt_file("/path/to/secret.pdf", "/path/to/secret.pdf.enc", "user_password")
def decrypt_file(input_path: str, output_path: str, password: str):
"""Decrypt a file with password."""
with open(input_path, 'rb') as file:
raw = file.read()
salt = raw[:16]
encrypted = raw[16:]
key = derive_key(password, salt)
f = Fernet(key)
decrypted = f.decrypt(encrypted)
with open(output_path, 'wb') as file:
file.write(decrypted)
print(f"Decrypted: {output_path} ({len(decrypted)} bytes)")
# Usage
decrypt_file("/path/to/secret.pdf.enc", "/path/to/secret.pdf", "user_password")
import os
def encrypt_directory(dir_path: str, password: str):
"""Encrypt all files in a directory."""
encrypted_dir = dir_path + "_encrypted"
os.makedirs(encrypted_dir, exist_ok=True)
count = 0
for filename in os.listdir(dir_path):
filepath = os.path.join(dir_path, filename)
if os.path.isfile(filepath):
encrypt_file(filepath, os.path.join(encrypted_dir, filename + ".enc"), password)
count += 1
print(f"Encrypted {count} files -> {encrypted_dir}")
development
Local web search (Tavily/Exa, requires API Key). For quick searches. If no Key configured or deep research needed, use cloud_agent instead.
development
Get current weather and forecasts (no API key required).
tools
Send WhatsApp messages to other people or search/sync WhatsApp history via the wacli CLI (not for normal user chats).
tools
Start voice calls via the Moltbot voice-call plugin.