国产gaysexchina男同gay,japanrcep老熟妇乱子伦视频,吃奶呻吟打开双腿做受动态图,成人色网站,国产av一区二区三区最新精品

Python菜譜1:創(chuàng)建一個(gè)唯一的 session ID

2018-07-25 18:17 更新

在網(wǎng)站開發(fā)的時(shí)候,常常需要生成一個(gè)唯一的的會(huì)話(session)id,這個(gè)會(huì)話 id 存儲(chǔ)在 cookie 中或者在其它安全的地方。:

create a unique session id
 input - string to use as part of the data used to create the session key.
        Although not required, it is best if this includes some unique
        data from the site, such as it's IP address or other environment
         information.  For ZOPE applications, pass in the entire ZOPE "REQUEST"
         object.
def makeSessionId(st):
        import md5, time, base64, string
        m = md5.new()
        m.update('this is a test of the emergency broadcasting system')
        m.update(str(time.time()))
        m.update(str(st))
        return string.replace(base64.encodestring(m.digest())[:-3], '/', '/span>)

def makeSessionId_nostring(st):
        import md5, time, base64
        m = md5.new()
        m.update('this is a test of the emergency broadcasting system')
        m.update(str(time.time()))
        m.update(str(st))
        return base64.encodestring(m.digest())[:-3].replace('/', '/span>)

輸入?yún)?shù):st,不限制 st 唯一,但是建議傳入的 st 是唯一的,可以是 IP 或者一些環(huán)境信息。 輸出:唯一的 session id 字符串。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)