Created
April 10, 2016 17:38
-
-
Save dogancankilment/a9e93b371e2ee1450effa9e1c08cdc82 to your computer and use it in GitHub Desktop.
Activation key generator for sending verification mail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import datetime | |
def activation_key_generator(email): | |
expire_date = datetime.datetime.today() + datetime.timedelta(3) | |
activation_key = base64.b64encode( | |
str(expire_date)) + base64.b64encode( | |
str(email)).split('=')[0] | |
return activation_key | |
# returning email in the activation_key | |
def tokens_email(token_id): | |
if "=" in token_id: | |
# or using with try except block | |
email = token_id.split('=')[1] + '==' | |
email = base64.b64decode(email) | |
return email | |
# returning expire date in activation_key | |
def tokens_expire_date(token_id): | |
expire_date_in = token_id.split('=')[0] + '=' | |
expire_date = base64.b64decode(expire_date_in) | |
return expire_date | |
if __name__ == '__main__': | |
email = "your@mail.com" | |
activation_key = activation_key_generator(email) | |
date_result = tokens_expire_date(activation_key) | |
mail_result = tokens_email(activation_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment