Skip to content

Commit

Permalink
Merge pull request #7 from jellonek/master
Browse files Browse the repository at this point in the history
py3fication
  • Loading branch information
bbangert committed Apr 27, 2012
2 parents 05122db + 888a449 commit e41fc3a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions beaker/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def _session_id():
class SignedCookie(Cookie.BaseCookie):
"""Extends python cookie to give digital signature support"""
def __init__(self, secret, input=None):
self.secret = secret
self.secret = secret.encode('UTF-8')
Cookie.BaseCookie.__init__(self, input)

def value_decode(self, val):
val = val.strip('"')
sig = HMAC.new(self.secret, val[40:], SHA1).hexdigest()
sig = HMAC.new(self.secret, val[40:].encode('UTF-8'), SHA1).hexdigest()

# Avoid timing attacks
invalid_bits = 0
Expand All @@ -67,7 +67,7 @@ def value_decode(self, val):
return val[40:], val

def value_encode(self, val):
sig = HMAC.new(self.secret, val, SHA1).hexdigest()
sig = HMAC.new(self.secret, val.encode('UTF-8'), SHA1).hexdigest()
return str(val), ("%s%s" % (sig, val))


Expand Down

0 comments on commit e41fc3a

Please sign in to comment.