File size: 300 Bytes
5830944
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import json, hashlib, time

_STORE = {}

def save_search(query, sources):
    payload = {"q": query, "s": sources, "t": int(time.time())}
    key = hashlib.sha256(json.dumps(payload).encode()).hexdigest()[:12]
    _STORE[key] = payload
    return key

def load_search(key):
    return _STORE.get(key)