Skip to content
Skills Library
Programming · Building & coding

pywayne-crypto

/pywayne-crypto

Encryption and decryption toolkit for string and byte data. Supports Fernet (AES-128) symmetric encryption, fallback XOR encryption, custom password protection, code obfuscation, and batch processing. Use when users need to encrypt/decrypt sensitive data, protect algorithms, or obfuscate Python code.

Licence
MIT
Last repository change
23.10.2026

Assessment and security

95/ 100Class: good
Format20 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 23.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Encryption and decryption toolkit for string and byte data. Supports Fernet (AES-128) symmetric encryption, fallback XOR encryption, custom password protection, code obfuscation, and batch processing. Use when users need to encrypt/decrypt sensitive data, protect algorithms, or obfuscate Python code.

Original author description

Encryption and decryption toolkit for string and byte data. Supports Fernet (AES-128) symmetric encryption, fallback XOR encryption, custom password protection, code obfuscation, and batch processing. Use when users need to encrypt/decrypt sensitive data, protect algorithms, or obfuscate Python code.

How it works

  1. Quick Start
  2. encrypt - 加密函数
  3. decrypt - 解密函数
  4. 批量操作
  5. 配置文件管理
  6. 加密策略
  7. 错误处理
  8. 最佳实践
Original SKILL.md headings · 152 lines, 349 words
SKILL.md preview
---
name: pywayne-crypto
description: Encryption and decryption toolkit for string and byte data. Supports Fernet (AES-128) symmetric encryption, fallback XOR encryption, custom password protection, code obfuscation, and batch processing. Use when users need to encrypt/decrypt sensitive data, protect algorithms, or obfuscate Python code.
---

# Pywayne Crypto

加密解密工具集,支持对称加密、自定义密码和代码混淆保护。

## Quick Start

```python
from pywayne.crypto import encrypt, decrypt

# 基础加密/解密
encrypted = encrypt("Hello World")
decrypted = decrypt(encrypted)
print(decrypted)  # 输出: Hello World

# 使用自定义密码加密
encrypted = encrypt("Secret message", "my_password")
decrypted = decrypt(encrypted, "my_password")
print(decrypted)  # 输出: Secret message
```

## encrypt - 加密函数

加密字符串或字节数据。

```python
# 文本加密
encrypted = encrypt("机密信息", "password")
# 字节加密
byte_data = b"binary data"
encrypted = encrypt(byte_data, "password")
```

**参数**:

| 参数 | 类型 | 说明 |
|------|------|------|
| `text` | str or bytes | 要加密的文本数据或字节数据 |
| `password` | str | 可选,自定义密码。不提供时使用默认密钥 |

**返回值**:`str` - base64 编码的加密字符串

**参数类型错误处理**:
- 当输入不是 `str` 或 `bytes` 时抛出 `ValueError`

## decrypt - 解密函数

解密之前加密的字符串。

```python
# 解密(使用默认密钥)
decrypted = decrypt(encrypted_text)

# 解密(使用自定义密码)
decrypted = decrypt(encrypted_text, "my_password")
```

**参数**:

| 参数 | 类型 | 说明 |
|------|------|------|
| `encrypted_text` | str | 要解密的 base64 编码字符串 |
| `password` | str | 可选,解密密码。必须与加密时使用的密码相同 |

**返回值**:`str` - 解密后的原始字符串

## 批量操作

支持批量加密和解密操作。

```python
from pywayne.crypto import encrypt, decrypt

data = ["数据1", "数据2", "数据3"]
password = "batch_password"

# 批量加密
encrypted_list = encrypt_batch(data, password)

# 批量解密
decrypted_list = decrypt_batch(encrypted_list, password)
```

**参数**:

| 函数 | 参数 | 说明 |
|------|------|------|
| `encrypt_batch(data_list, password)` | data_list: 数据列表 | password: 密码 |
| `decrypt_batch(encrypted_list, password)` | encrypted_list: 加密数据列表 | password: 密码 |

**返回值**:`list[str]` - 解密结果列表(失败项目为 None)

## 配置文件管理

保存和加载加密配置文件(JSON 格式)。

```python
from pywayne.crypto import encrypt, decrypt

# 保存配置
config = {"database": {"host": "localhost", "username": "admin", "password": "secret"}}
save_config(config, "master_password", "config.enc")

# 加载配置
loaded_config = load_config("master_password", "config.enc")
print(loaded_config)  # 输出: {'database': {...}}
```

**参数**:

| 函数 | 参数 | 说明 |
|------|------|------|
| `save_config(config_dict, password, filename)` | config_dict: 配置字典 | password: 加密密码 | filename: 输出文件名 |
| `load_config(password, filename)` | password: 解密密码 | filename: 配置文件名 |

**异常**:
- `ValueError`:配置文件解密失败(密码错误或数据损坏)

## 加密策略

模块采用分层加密策略,优先使用 Fernet,回退到 XOR。

| 策略 | 说明 |
|------|------|------|
| **Fernet 加密**(推荐) | AES-128 对称加密,带消息完整性验证 |
| **XOR 加密**(回退) | 简单异或加密,无依赖,基本功能 |
| **代码混淆保护** | Base64 编码隐藏、动态函数生成、命名空间清理 |

## 错误处理

完善的异常处理机制,支持密码错误、数据格式错误、解密失败等情况。

```python
# 密码错误
try:
    decrypted = decrypt(encrypted_text, "wrong_password")
except ValueError:
    print("错误: 解密失败,密码不正确")

# 数据格式错误
try:
    encrypted = encrypt(123)
except ValueError:
    print("错误: 输入类型必须是字符串或字节")
```

## 最佳实践

- 密码妥善保管,避免硬编码在源码中
- 高安全性要求的应用使用专业加密库
- 密钥通过环境变量传递,避免写入日志

Versions

The database has no other skills named pywayne-crypto.

Database snapshot: 13.11.2026 · package version 9573f80d81fe (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100arbiter-services
    Use when the user needs Arbiter.Services utilities — CSV reading/writing (CsvReader / CsvWriter), AES or XOR encryption, cache key building (CacheTagger), continuation tokens, numeric encoding, glob matching, URL building (UrlBuilder, QueryStringEncoder), or secure token generation (TokenService).
  • 100ffmpeg-drm
    DRM and media encryption with ffmpeg: HLS AES-128 (-hls_key_info_file, -hls_enc, key rotation), HLS SAMPLE-AES, MPEG-DASH Common Encryption (CENC) with cenc_mp4 / cbcs schemes, ClearKey, fmp4 encrypted segments, cryptor protocol for playback. Use when the user asks to encrypt an…
  • 100dotnet-reactor
    Use when protecting .NET assemblies from reverse engineering or adding license enforcement — Necrobit IL encryption, obfuscation, string encryption, control-flow obfuscation, anti-debug/anti-tamper, License Manager serials, dotNET_Reactor.Console CI runs, merge assemblies. Also…
  • 100cryptonet
    Guidance for CryptoNet cryptography library in .NET. USE FOR: RSA encryption/decryption, symmetric AES encryption, X.509 certificate-based crypto, self-signed certificate generation, key pair management, encrypting sensitive data at rest. DO NOT USE FOR: password hashing (use…
  • 100applied-cryptography-symmetric-aes-gcm-chacha20
    Use this skill when encrypt data at rest and in transit using authenticated symmetric ciphers AES-256-GCM and ChaCha20.
  • 100implementing-aes-encryption-for-data-at-rest
    Guides implementing AES-256 encryption in GCM mode (FIPS 197) for files and data stores at rest, covering key derivation, IV/nonce management, and authenticated encryption. Use when deploying or configuring encryption for data at rest, establishing controls to meet compliance…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.