Metadata-Version: 2.4
Name: basic-crypt
Version: 1.5.2
Summary: Basic crypto primitives
Author: simendi
Author-email: simendi@gmail.com
License: MIT
Keywords: crypto,xor,crc32,rc4,cipher,abi3
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

`xor_bytes` and `crc32` are implemented in C against the
[CPython Stable ABI](https://docs.python.org/3/c-api/stable.html) (`abi3`),
so a single wheel (`cp38-abi3`) works on CPython 3.8 and newer; pure-Python
fallbacks are used automatically when the extension is unavailable (e.g. on
PyPy). Everything else is pure Python.

## Installation

```bash
pip install basic-crypt
```

## Usage

```python
import basic_crypt as bc

bc.xor_bytes(b"attack at dawn", b"key")            # b'\x1b\x00\x15\x06j...'
bc.xor_bytes(bc.xor_bytes(b"secret", b"k"), b"k")  # b'secret'
bc.crc32(b"123456789")                             # 3421780262 (0xCBF43926)

bc.rot13("Hello, World!")                          # 'Uryyb, Jbeyq!'
bc.atbash("Hello")                                 # 'Svool'
bc.affine_encrypt("AFFINE", 5, 8)                  # 'IHHWVC'
bc.affine_decrypt("IHHWVC", 5, 8)                  # 'AFFINE'
bc.railfence_encrypt("WEAREDISCOVEREDFLEEATONCE", 3)
bc.railfence_decrypt("WECRLTEERDSOEEFEAOCAIVDEN", 3)
bc.rc4(b"Plaintext", b"Key").hex()                 # 'bbf316e8d940af0ad3'
```

`basic_crypt.native_available()` reports whether the compiled `_native`
extension is in use.

## API reference

| Function | Description |
|---|---|
| `xor_bytes(data, key)` | Repeating-key XOR over any bytes-like objects |
| `crc32(data)` | zlib-compatible CRC-32 checksum (IEEE 802.3) as `int` |
| `rot13(text)` | ROT13 substitution on letters |
| `atbash(text)` | Atbash (A↔Z) substitution on letters |
| `affine_encrypt(text, a, b)` | Affine cipher; requires `gcd(a, 26) == 1` |
| `affine_decrypt(text, a, b)` | Inverse of `affine_encrypt` |
| `railfence_encrypt(text, rails)` | Rail fence transposition |
| `railfence_decrypt(text, rails)` | Inverse of `railfence_encrypt` |
| `rc4(data, key)` | RC4 stream cipher (symmetric) |
| `native_available()` | `True` if the compiled abi3 extension is in use |

## License

MIT — see [LICENSE](LICENSE).
