mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2025-03-29 00:46:41 +00:00
Merge pull request #104 from obiwan69/master
added RSA-key-pair generator
This commit is contained in:
commit
8a49730dad
@ -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) |
|
|[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) |
|
|[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)|
|
|[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)|
|
|[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)|
|
|[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)|
|
|[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
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…
x
Reference in New Issue
Block a user