Skip to main content

ElGamal encryption

Project description

elgamal-anass-daniel

A friendly module for testing ElGamal Cryptosystem. Moreover, it also brings futures such as validating primitive roots, obtaining them, and optimized operations such as Fast Modular Exponentiation.

Developed by Anass Anhari & Daniel Alamillo (c) 2023

Examples of How To Use

ElGamal built-in and optimized operations:

from ElGamal import ElGamal

elGamal = ElGamal()

# Fast Modular Exponentiation
elGamal.FastModExp(g=2, e=284523875345345, p=456), 32) # 32
elGamal.FastModExp(g=100, e=284523875345345, p=456)    # 256

# Obtain Primitive Roots
elGamal.getPrimitiveRoots(5)  # [2, 3]
elGamal.getPrimitiveRoots(29) # [2, 3, 8, 10, 11, 14, 15, 18, 19, 21, 26, 27]

# Obtain the First Primitive Root
elGamal.getFirstPrimitiveRoot(6) # None
elGamal.getPrimitiveRoots(29)    # 2

# Test a Primitive Root
elGamal.isPrimitive(725, 829) # True
elGamal.isPrimitive(41, 101)  # False

msg1 = ElGamal.Message("[Msg-1] Hola que tal estas! :D")
msg1.encrypt(g=2, g_x=1024, p=8820220609)
print(msg1.decrypt(x=10, p=8820220609))

Create a message, encrypt it and decrypt it:

from ElGamal import Message

msg1 = Message("[Msg-1] Hola que tal estas! :D")
msg1.encrypt(g=2, g_x=1024, p=8820220609)
print(msg1.decrypt(x=10, p=8820220609))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elgamal-anass-daniel-0.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elgamal_anass_daniel-0.0.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file elgamal-anass-daniel-0.0.2.tar.gz.

File metadata

  • Download URL: elgamal-anass-daniel-0.0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for elgamal-anass-daniel-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b3e5a2610fe825c3a3915ec02b7a7c67ba8f4360e261b3938f2aad0a68a22d0a
MD5 9f664c5d4f614c9ba75c20a7b16225f5
BLAKE2b-256 c9ccc408bde79f74552d96c128c6548efb7d4e8a1aec0f118f963f61bbc19fa1

See more details on using hashes here.

File details

Details for the file elgamal_anass_daniel-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for elgamal_anass_daniel-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a084b9f1f5613c3a196efa1b325e9c1328f62d3777047b30f4aae773cb42378a
MD5 2967a558a5b015e14171e89e4e9929da
BLAKE2b-256 c1c85b5f36d9c4d951cfef006a1fd1853db2d1416c14c0e04dbabfe66c0bf9f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page