mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
Create key-pair-generator.py
Create description.md Create requirements.txt Rename description.md to README.md Update requirements.txt Update README.md
This commit is contained in:
parent
fa307e01a0
commit
ab66a7a474
|
@ -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) |
|
||||
|
||||
## How to use :
|
||||
|
||||
|
|
21
RSA-key-pairs/README.md
Normal file
21
RSA-key-pairs/README.md
Normal 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)
|
||||
```
|
20
RSA-key-pairs/key-pair-generator.py
Normal file
20
RSA-key-pairs/key-pair-generator.py
Normal 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,')')
|
1
RSA-key-pairs/requirements.txt
Normal file
1
RSA-key-pairs/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
|
Loading…
Reference in New Issue
Block a user