
Python向けの自己完結型暗号ライブラリ
.. image:: https://github.com/Legrandin/pycryptodome/workflows/Integration%20test/badge.svg :target: https://github.com/Legrandin/pycryptodome/actions
.. image:: https://badge.fury.io/py/pycryptodome.svg :target: https://pypi.org/project/pycryptodome
PyCryptodome は、低レベル暗号プリミティブを提供する自己完結型の Python パッケージです。pip install を一度実行するだけで、システムライブラリは不要であり、AES や RSA から HPKE、KangarooTwelve、耐量子 ML-DSA まで、幅広く一貫した API を提供します。
Python 3.9 以降と PyPy をサポートしています。
インストールは次のコマンドで行います::
pip install pycryptodome
すべてのモジュールは Crypto パッケージの下にインストールされます。
.. code-block:: python
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
key = get_random_bytes(32)
cipher = AES.new(key, AES.MODE_GCM) # a random nonce is generated
ciphertext, tag = cipher.encrypt_and_digest(b"attack at dawn")
receiver = AES.new(key, AES.MODE_GCM, nonce=cipher.nonce)
plaintext = receiver.decrypt_and_verify(ciphertext, tag) # raises ValueError if tampered
.. note::
バージョン 3.x までは、このライブラリは pycryptodomex プロジェクトとしてもリリースされ、Cryptodome パッケージの下にインストールされていました。
バージョン 4.0 以降、pycryptodomex はリリースされなくなり、Crypto が唯一のパッケージ名です。
移行するには、インポート内の Cryptodome を Crypto に置き換えてください。
アルゴリズムと形式の完全なリストについては、features page_ を参照してください。
その他の情報については、homepage_ を参照してください。
セキュリティに関する問題については、[email protected] までメールをお送りください。
すべてのコードは GitHub_ からダウンロードできます。
.. _homepage: https://www.pycryptodome.org
.. _features page: https://www.pycryptodome.org/src/features
.. _GitHub: https://github.com/Legrandin/pycryptodome