Skip to content

Instantly share code, notes, and snippets.

@bala-codes
Last active January 29, 2021 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bala-codes/06f5c6ae0f5481ffe573c8463cc2b3f1 to your computer and use it in GitHub Desktop.
Save bala-codes/06f5c6ae0f5481ffe573c8463cc2b3f1 to your computer and use it in GitHub Desktop.
Code Encryption / Obfuscation
import os, json, sys
from datetime import datetime
def inference(name="", tag = True):
'''
if the current year is 2021, then inference function will run successfully, otherwise fails.
Here the attribute variable holds the string version of the date in MM-DD-YYYY format
'''
print("Hello {}, the inference function has been successfully started".format(name))
attribute = str(datetime.now().strftime('%m-%d-%Y'))
response = "You license has been expired, please contact us."
year_to_expire = int(2022)
try:
assert int(attribute.split('-')[-1]) == year_to_expire, response
except AssertionError as e:
print(response)
sys.exit()
# Replace your main code to operate here.
# if the above assertion is True, it will reach until this point, otherwise it will stop in the previous line.
if tag:
print("inference function has been completed successfully")
return True
else:
return False
if __name__ == "__main__":
_ = inference(name="Bala")
'''
Function outputs,
Case 1: if year_to_expire = int(2021)
Hello Bala, the inference function has been successfully started
inference function has been completed successfully
[Finished in 0.2s]
Case 2: if year_to_expire = int(2022)
Hello Bala, the inference function has been successfully started
You license has been expired, please contact us.
[Finished in 0.2s]
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment