def validateSessionCookie(self): userIdCookie_str = self.request.cookies.get("userId") if userIdCookie_str: userId = userIdCookie_str.split("|")[0] if(utils.valid_hash(userId,userIdCookie_str)): return userId return False
def list_nifty_gateway(update=True, verbose=False): cache_fn = 'data/nifty-gateway-contracts.json' cache = {} if os.path.exists(cache_fn): if verbose: print('Loading Nifty Gateway contracts from cache...') with open(cache_fn) as f: cache = json.load(f) if not update: if verbose: print('Returning Nifty Gateway contracts from cache...') return cache cache = {v: k for k, v in cache.items()} # swap key/value blocklist = generate_blocklist() if verbose: print('Downloading from drops...') for current_page in count(1): url = f'https://api.niftygateway.com/drops/open/?size=100¤t={current_page}' res = requests.get(url) results = json.loads(res.content)['listOfDrops'] if len(results) == 0: break for drop in results: for item in drop['Exhibitions']: contract = item['contractAddress'] url = item['storeURL'] key = 'Nifty Gateway/' + url if not valid_hash(contract, blocklist): print('skipping', key, contract) if contract in cache: print('deleting old contract', contract) del cache[contract] continue cache[contract] = key if verbose: print('Page', current_page, 'total', len(cache)) if verbose: print('Done.') if verbose: print(f'Filtered: total {len(cache)}') cache = {v: k for k, v in cache.items()} # swap key/value with open(cache_fn, 'w') as f: json.dump(cache, f, indent=2) return cache
if __name__ == '__main__': # Get the list of parameters passed from command line options = CliArgs('hash') if options.verbosity: logger.setLevel(logging.INFO) else: logger.setLevel(logging.WARNING) if options.filehash is None: options.filehash = raw_input("Input File Hash: ") print "###############" # this should exit with string try: utils.valid_hash(options.filehash) except Exception as inst: print inst sys.exit(1) if options.verbosity: utils.license() # Options wrapper for DXLClientConfig try: dxlconfig = DxlConfigWrapper(options) except Exception as inst: print inst sys.exit(1) # Create the client
def validatePassword(self, password, hashedPass): passValid = utils.valid_hash(password,hashedPass) return passValid