mod – modular arithmetic in Python
Description
Modular arithmetic is arithmetic for integers, where numbers wrap around when reaching a given value called modulus. For example 6 ≡ 1 (mod 5). Modular arithmetic has several practical applications including: music, banking, book publishing, cryptography… and of course math.
The purpose of this package is to simplify the use of modular arithmetic in Python3.
Usage
This package provides Mod integers that compute arithmetic operations like + - * // ** with a modulus:
from mod import Mod
# Funny math here
x = Mod(5, 7) # x ≡ 5 (mod 7)
(x + 2) == 0 # True: 5 + 2 ≡ 7 ≡ 0 (mod 7)
(x + 7) == x # True: 5 + 7 ≡ 12 ≡ 5 (mod 7)
(x**3) == (x + 1) # True: 5³ ≡ 125 ≡ 6 (mod 7)
(1 // x) == 3 # True: 5 × 3 ≡ 15 ≡ 1 (mod 7) ⇒ 5⁻¹ ≡ 3 (mod 7)
A naive implementation of RSA encryption algorithm using mod package:
from mod import Mod
# My RSA keys
public_key = Mod(3, 61423)
private_key = Mod(40619, 61423)
# My very secret message
top_secret_message = 666
# RSA encryption
encrypted = top_secret_message**public_key
# RSA decryption
decrypted = encrypted**private_key
# My secret message have been correctly encrypted and decrypted :-)
assert decrypted == top_secret_message
Package documentation: mod.Mod
Install
Run the following command to install mod package
pip3 install mod
Links
Package documentation located at http://mod.readthedocs.io/en/latest/
Python package available at https://pypi.python.org/pypi/mod
Source code repository: https://github.com/yoeo/mod
Indices
mod — Copyright (c) 2020 Y. SOMDA, MIT License
Metadata
Release files for mod 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mod-0.3.0.tar.gz | 4.4 kB | Without provenance | Details for mod-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mod-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for mod-0.3.0-py3-none-any.whl |
Total release size: 9.4 kB
Release files / mod-0.3.0.tar.gz
| Download URL | mod-0.3.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3462cb997ba4cb393fe91ebc8b94e574d93ae59ef6df8b13fdd44192b242842
|
|
BLAKE2b-256 checksum How to use checksums |
f172ef6f03a29c7b5da29fe05856716985efb51b3095e3ea31433638e3e3f64f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5
|
Release files / mod-0.3.0-py3-none-any.whl
| Download URL | mod-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0416727a7172d426860185cfbf416268eb9dd1b44677eda000c0703304b23e2
|
|
BLAKE2b-256 checksum How to use checksums |
aca4bcd7f8c9bd1c4bc1c6ea7d1aa39cea0b38d8303f6f06994cac5264ecae22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5
|
Security for mod 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.