Merge pull request #104 from obiwan69/master

added RSA-key-pair generator
This commit is contained in:
Ayush Bhardwaj 2019-10-22 13:57:48 +05:30 committed by GitHub
commit 8a49730dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 0 deletions

View File

@ -71,6 +71,7 @@ So far, the following projects have been integrated to this repo:
|[IMDB TV Series Info Extractor](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/imdb_episode_ratings)|[Yash Raj Sarrof](https://github.com/yashYRS) |
|[Yoda-speak Translator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/speak_like_yoda)|[sonniki](https://github.com/sonniki) |
|[Medium Article Downloader](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/medium_article_downloader)|[coolsonu39](https://github.com/coolsonu39)|
|[RSA Key Pair Generator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/RSA-key-pairs) | [Aditya Parikh](https://github.com/obiwan69) |
|[Clean_up_photo](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Clean_up_photo)|[sritanmay001](https://github.com/sritanmy001)|
|[PyRecorder](./PyRecorder)|[Rocky Jain](https://github.com/jainrocky)|
|[Pretty CSV](https://github.com/Frizz925/Awesome-Python-Scripts/tree/pretty-csv/Pretty-CSV)|[Frizz925](https://github.com/Frizz925)|

21
RSA-key-pairs/README.md Normal file
View File

@ -0,0 +1,21 @@
# Python RSA Key Pair Generator
This python script will generate a private and public key pair using the RSA algorithm
## Modules used
Math
```
import math
```
Random
```
import random
```
#Usage
You can use the public and private key to encrypt and decrypt information
Run the python file and get key pairs or edit the code and define your custom bounds in the random limits
```
random.randint(start,end)
```

View File

@ -0,0 +1,20 @@
#a simple RSA public key and private key pair generator
#using gcd from math module for coprimes
#and random for random numbers
import math
import random
p = random.randint(1,100)
q = random.randint(100,200)
if (math.gcd(p,q) == 1):
n = p * q
phi = (p-1)*(q-1)
k = 0
e = random.randint(1,20000)
if (math.gcd(phi,e)==1):
for i in range(1,20000):
d = (((phi * i) + 1)/e)
if d.is_integer():
k = d
break
print('Public key is: (',e,',',n,')')
print('Private key is: (',int(k),',',n,')')

View File

@ -0,0 +1 @@