Giter VIP home page Giter VIP logo

elgamalcrypto's Introduction

elgamalcrypto

Simple Python Elgamal Encryption and Decryption Tool

This script was mostly used for me to learn how Elgamal works.

Helpful Resources:

Dependencies

  • pip install sympy - This is so the prime generator works quickly.

Example 2 Character Run with Verification

$ time ./elgamal.py
Warning: Anthing more than 3 characters could take a very long time to encrypt
Enter message to encrypt: it
Bob's MESSAGE         : it
MESSAGE as an int (M) : 26996
Prime number (P)      : 61253
Generator (G)         : 23087
Alice private key (X) : 16103
Bob's private key (R) : 20490
Shared secret (H)     : 36479
Encrypted Message (C1): 2362
Encrypted Message (C2): 6772
Decrypted Integer (dm): 26996
Decrypted Hex (x)     : 6974
Decrypted Message     : b'it'

real	0m1.649s
user	0m0.285s
sys	0m0.016s

Example with long string

$ time python3 elgamal.py
Enter message to encrypt: This is a really long string for no reason what-so-ever
Bob's MESSAGE         : This is a really long string for no reason what-so-ever
MESSAGE as an int (M) : 936140450767113267965789526506206491929878298146895212622982486833192086180233170932959949678546085654866949395518767919304942183794
Prime number (P)      : 2732202483472796230552840939786318149552066588599751316514585894733284183141658331370522061142362270191703995600531377432565986089031
Generator (G)         : 655051988642726440100234687727361472241223194387260073776944847766833641196630019073062148005250400958985997330463328889516727075079
Alice private key (X) : 759674118901119348774184676944860416595917004750602667671245059401420763383429179379996432597693268146910211930534447853089180047520
Bob's private key (R) : 530420356334113032058135128983933150355974091171544040555800126132154593233892663946504466711210276928087150715709683081110998867178
Shared secret (H)     : 1195060212862396082267954454059138979164671228535241606217594017391958535941383354001276446149980324540386667396871095354193818516142
Encrypted Message (C1): 1971857674999162819409737910956982050157708632477310671437408306318414041292922331067272518172493225247118459514061942412333141234874
Encrypted Message (C2): 1036301610490361359363167858384995423342345422198137655235881896615316223008088446518190790078611876164254030601248558708515780484023
Decrypted Integer (dm): 936140450767113267965789526506206491929878298146895212622982486833192086180233170932959949678546085654866949395518767919304942183794
Decrypted Hex (x)     : 546869732069732061207265616c6c79206c6f6e6720737472696e6720666f72206e6f20726561736f6e20776861742d736f2d65766572
Decrypted Message     : b'This is a really long string for no reason what-so-ever'

real    0m12.437s
user    0m0.297s
sys     0m0.156s

elgamalcrypto's People

Contributors

mubix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.