I hadn't noticed before: `b64encode' has an optional argument which you
can use to change the `+' and `/' characters. Use them instead of a
post-pass with `str.replace'.
def hack_octets(s):
"""Return the octet string S, in a vaguely pretty form."""
def hack_octets(s):
"""Return the octet string S, in a vaguely pretty form."""
- return BN.b64encode(s) \
- .rstrip('=') \
- .replace('/', '$')
+ return BN.b64encode(s, '+$').rstrip('=')
def auth_tag(sec, stamp, nonce, user):
"""Compute a tag using secret SEC on `STAMP.NONCE.USER'."""
def auth_tag(sec, stamp, nonce, user):
"""Compute a tag using secret SEC on `STAMP.NONCE.USER'."""