#!/usr/bin/env python3 from cryptography.fernet import Fernet as frt key="" #Add key token="" #Add toke print('key: {0}, type: {1}'.format(key, type(key))) print('token: {0}, type: {1}'.format(token, type(token))) f=frt(key) output = f.decrypt(bytes(token, 'utf-8')) output_decoded = output.decode('utf-8') print ('decrypted: {0}'.format(output_decoded))
def decode(request, s): f = frt(request.session['key'].encode('utf-8')) token = f.decrypt(s.encode('utf-8')) # print(token.decode('utf-8')) return token.decode('utf-8')
def decode(request, s): f = frt(request.session['key'].encode('utf-8')) token = f.decrypt(s.encode('utf-8')) # print(token.decode('utf-8')) return token.decode('utf-8') # def compute(request,count): # i=datetime.strptime('2020413', '%Y%m%d') # # print(str(i.date())) # j=0 # obj=[] # temp_label=[] # temp_obj=[] # label=[] # temp_status=[] # status=[] # c=1 # today=datetime.now() # threshold=today-timedelta(days=8) # today=today.strftime('%Y-%m-%d') # # today=datetime.strptime('2020505', '%Y%m%d') # # print(today) # # if str(i.date()) == str(today): # # print("yes") # # else: # # print("no") # # print(i) # # print(type(i.date())) # # print(today) # # print(str(i.date())) # flag=0 # days=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] # # print(type(i.date())) # # print(type(threshold.date())) # # p=i.date()<threshold.date() # # print(p) # while str(i.date()) != today: # temp_obj.append(count[i.date()]) # if count[i] == None: # temp_obj.append(0) # temp_label.append(days[i.date().weekday()]) # # print(label[j]," ",obj[j]) # c=c+1 # i=i+timedelta(days=1) # if c % 8 == 0 and i.date() <= threshold.date(): # obj.append(temp_obj) # label.append(temp_label) # # status.append(temp_status) # temp_obj=[] # temp_label=[] # # temp_status=[] # c=1 # continue # elif i.date() > threshold.date() and temp_label != None: # # print("here") # flag=1 # if c % 8 == 0 : # obj.append(temp_obj) # label.append(temp_label) # # status.append(temp_status) # temp_obj=[] # temp_label=[] # # temp_status=[] # c=1 # continue # if flag==1: # # print("here23") # obj.append(temp_obj) # label.append(temp_label) # # status.append(temp_status) # temp_obj=[] # temp_label=[] # # temp_status=[] # print('labels:',label) # print('data:',obj) # # print('status:',status) # return [label,obj]