Metadata-Version: 2.4
Name: pycksum
Version: 0.6.1
Summary: Python implementation of cksum algorithm
Author-email: Lewis Sobotkiewicz <lewis.sobot@gmail.com>
License-Expression: MIT
Project-URL: Repository, https://github.com/sobotklp/pycksum
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# pycksum - A Python implementation of the cksum algorithm

[![Build](https://github.com/sobotklp/pycksum/workflows/CI/badge.svg?branch=master)](https://github.com/sobotklp/pycksum/actions?workflow=CI) [![PyVersion](https://img.shields.io/badge/python-3.10+-blue.svg)]() [![PyPiVersion](https://img.shields.io/pypi/v/pycksum.svg)](https://pypi.python.org/pypi/pycksum) [![License](https://img.shields.io/badge/license-MIT-yellow.svg)]()

The `cksum` algorithm generates a checksum for a stream of data. While cksum is not cryptographically strong, it can be used to validate the integrity of transferred files.

Pycksum includes a pure Python implementation of `cksum` as well as an efficient C extension that will automatically be used on platforms that support it.

## Installation

Install from PyPi using pip, a package manager for Python:

```
$ pip install pycksum
```

## Examples

The simplest way to use pycksum is to just give it a string:

```python
import pycksum
ck = pycksum.cksum("Any string")
```

You can pass in a file or an iterable:

```python
ck = pycksum.cksum( open("filename"))

ck = pycksum.cksum( ["This", "love", "is", "taking", "its", "toll", "on me"])
```

If you have a lot of data to process, it's more memory-efficient to calculate the cksum incrementally:

```python
c = pycksum.Cksum()
for data in input_fd:
    c.add(data)
ck = c.get_cksum()
sz = c.get_size()
```
