all repos — myprecious @ bf1121dbaf0e48befb0831a845cd069e9e546519

A lightweight web service to backup precious game saves.

myprecious/encoding.py (view raw)

 1import base64, json
 2
 3def obj_decode(text):
 4    base64_bytes = text.encode('utf-8')
 5    message_bytes = base64.b64decode(base64_bytes)
 6    message = message_bytes.decode('utf-8')
 7    return json.loads(message)
 8
 9def obj_encode(info):
10    temp_json = json.dumps(info)
11    temp_bytes = temp_json.encode("utf-8")
12    temp_base64 = base64.b64encode(temp_bytes)
13    return temp_base64.decode("utf-8")