Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bcrypt.gensalt and hashpw #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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