Skip to content

rubulubu/prsa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSA implementation (Python)

Implementation of the algorithms defined by the RSA scheme as a Command Line Utility. Computes ciphertext from message and Computes message from ciphertext granted access to secret decryption key by using Extended Euclidean Algorithm, Unicode Points, Modular Arithmetic and Modular Exponentiation

Setup

pip install primesieve
pip install prsa

What is the RSA Scheme?

RSA is one of the first practical public-key cryptosystems and is widely used for secure data transmission. In this cryptosystem, the encryption key is public and differs from the decryption key which is kept secret. In RSA, this asymmetry is based on the practical difficulty of factoring the product of two large prime numbers, the factoring problem. RSA is made of the initial letters of the surnames of Ron Rivest, Adi Shamir, and Leonard Adleman - The minds behind the RSA Scheme.

Usage

Help

~$ prsa -h
usage: PRSA [-h] {decrypt,encrypt,generate} ...

Implementation of the algorithms defined by the RSA scheme in Python3.
Computes ciphertext from message and Computes message from ciphertext granted
access to secret decryption key by using Extended Euclidean Algorithm, Unicode
Points, Modular Arithmetic and Modular Exponentiation

positional arguments:
  {decrypt,encrypt,generate}
    decrypt             Decrypt ciphertext using RSA
    encrypt             Encrypt message using RSA
    generate            Find a key pair given the two natural numbers

optional arguments:
  -h, --help            show this help message and exit

Generate Help

~$ prsa generate -h
usage: PRSA generate [-h] p q

positional arguments:
  p           An integer for setting a prime (p)
  q           An integer for setting a prime (q)

optional arguments:
  -h, --help  show this help message and exit

Encrypt Help

~$ prsa encrypt -h
usage: PRSA encrypt [-h] M e n

positional arguments:
  M           Message to be encrypted
  e           A natural number that serves as the first element of the public
              key
  n           A natural number that serves as the second element of the
              private key

optional arguments:
  -h, --help  show this help message and exit

Decrypt Help

~$ prsa decrypt -h
usage: PRSA decrypt [-h] C d n

positional arguments:
  C           Encoded ciphertext to be decrypted
  d           A natural number that serves as the first element of the private
              key
  n           A natural number that serves as the second element of the
              private key

optional arguments:
  -h, --help  show this help message and exit

Example

Generate Keys, Encrypt 'msg' and then Decrypt

~$ prsa generate 31974198 84197413
   {
	'Public': [579312365, 1042765315429168511L], 
	'Private': [802880348865349973L, 1042765315429168511L],
   }

~$ prsa encrypt "msg" 579312365 1042765315429168511
   585349761260265530

~$ prsa decrypt 585349761260265530 802880348865349973 1042765315429168511
   msg

Disclaimer

Purely experimental project. Designed for learning purposes not production use.

Contributing

Bug reports and pull requests are welcome on GitHub at @ridwanmsharif

Author

Ridwan M. Sharif: E-mail, @ridwanmsharif

License

The command line utility is available as open source under the terms of the MIT License

About

RSA Public Key Encryption

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.2%
  • Shell 1.8%