main.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:appengine_multiblog 作者: tstillwell 项目源码 文件源码
def secret_key():
    """ Get secret key from datastore.

        Read Secret Key from db. If one does not exist, create one
        and the event gets logged since this is an important security event
    """
    secret_check = ndb.gql("SELECT key_string FROM Secret")
    key = secret_check.get()
    if key:  # if key is present return it
        return key.key_string
    else:  # if not make one and return/store it
        new_key = binascii.b2a_hqx(os.urandom(64))  # 64-bits of ASCII
        k = Secret(key_string=new_key)
        k.put()
        logging.critical("A NEW SECRET KEY HAS BEEN CREATED FOR HMAC")
        return new_key
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号