Danger

Nothing here should be used for any security purposes.

  • If you need cryptographic tools in a Python environment use pyca.

  • If you need efficient and reliable abstract math utilities in a Python-like environment consider using SageMath.

Toy cryptographic functions and utilities

Some toy (unsafe for actual use) cryptography related utilites.

Installation

Remember that nothing here is build to be used for security purposes, but if you must:

python3 -m pip install toycrypto --user

Import names

Once installed, the modules are imported under toy_crypto. For example, Number Theory module would be imported with import toy_crypto.nt.

>>> from toy_crypto.nt import factor
>>> n = 69159288649
>>> factorization = factor(n)
>>> factorization.data
[(11, 2), (5483, 1), (104243, 1)]
>>> str(factorization)
'11^2 * 5483 * 104243'
>>> factorization.n == n
True
>>> factorization.phi
62860010840

Note again that the SageMath Factorization class is far more efficient and general than what exists in this toy cryptography module.

Table of Contents