Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions util/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from Crypto.PublicKey import RSA
import binascii
import random
import requests
import os

def verfiyKey(key: str):
try:
if len(key) < 750:
return False
RSA.importKey(binascii.unhexlify(key))
# .publickey().exportKey('PEM')
return True
except:
return False


# function for otp generation
def otpgen():
otp=""
for i in range(4):
otp+=str(random.randint(1,9))
return otp


def SendOtp(mail, frm):
otp=otpgen()
requests.post(
"https://api.eu.mailgun.net/v3/account.vote-chain.tech/messages",
auth=("api", os.environ.get('mailGunAPI')),
data={"from": "VoteChain verification <{}@account.vote-chain.tech>".format(frm),
"to": [mail],
"subject": "Account verification | VoteChain",
"template": "otpsend",
"v:otp":otp})
return otp
Footer