diff --git a/CHANGELOG.md b/CHANGELOG.md index 58c8b13..a1a0f94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Added - AffineCipher.invert method to obtain the inverse cipher +### Changed +- Depend on cython~=3.0 ## [0.0.3] - 2024-10-14 diff --git a/pyproject.toml b/pyproject.toml index 8b4c3b0..22e616f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ Issues = "https://github.com/jfolz/shufflish/issues" Changelog = "https://github.com/jfolz/shufflish/blob/main/CHANGELOG.md" [build-system] -requires = ["setuptools>=50.0.3", "wheel", "cython~=3.0.0", "setuptools_scm"] +requires = ["setuptools>=50.0.3", "wheel", "cython~=3.0", "setuptools_scm"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] diff --git a/shufflish/_affine.pyx b/shufflish/_affine.pyx index 50ca20f..97b84bc 100644 --- a/shufflish/_affine.pyx +++ b/shufflish/_affine.pyx @@ -123,6 +123,16 @@ cdef class AffineCipher: self.params.post_offset, )) + def __eq__(self, other): + if not isinstance(other, AffineCipher): + return False + cdef AffineCipher other_ = other + cdef affineCipherParameters oparams = other_.params + return self.params.domain == oparams.domain \ + and self.params.prime == oparams.prime \ + and self.params.pre_offset == oparams.pre_offset \ + and self.params.post_offset == oparams.post_offset + def parameters(self): """ Returns the affine parameters as tuple @@ -135,16 +145,6 @@ cdef class AffineCipher: self.params.post_offset, ) - def __eq__(self, other): - if not isinstance(other, AffineCipher): - return False - cdef AffineCipher other_ = other - cdef affineCipherParameters oparams = other_.params - return self.params.domain == oparams.domain \ - and self.params.prime == oparams.prime \ - and self.params.pre_offset == oparams.pre_offset \ - and self.params.post_offset == oparams.post_offset - def invert(self) -> AffineCipher: """ Returns the inverse of this affine cipher, i.e.,