aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/webui/utils.py
blob: 6ae81e97d2463faf2181bd7d0eb17792ca639c0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (c) 2016 Weitian LI <liweitianux@live.com>
# MIT license

"""
Utilities for the Web UI
------------------------

gen_cookie_secret :
    Generate the secret key for cookie signing from the local hostname.
"""


import socket
import base64


def gen_cookie_secret():
    """
    Generate the secret key for cookie signing from the local hostname.
    """
    hostname = socket.gethostname()
    secret = base64.b64encode(hostname.encode("utf-8")).decode("ascii")
    return secret