Ticket #16182: 16182-increased-signing-precision.diff

File 16182-increased-signing-precision.diff, 925 bytes (added by floguy, 13 years ago)

Increased precision for TimestampSigner

  • django/core/signing.py

     
    159159
    160160class TimestampSigner(Signer):
    161161    def timestamp(self):
    162         return baseconv.base62.encode(int(time.time()))
     162        return baseconv.base62.encode(int(time.time() * 10000))
    163163
    164164    def sign(self, value):
    165165        value = smart_str('%s%s%s' % (value, self.sep, self.timestamp()))
     
    168168    def unsign(self, value, max_age=None):
    169169        result =  super(TimestampSigner, self).unsign(value)
    170170        value, timestamp = result.rsplit(self.sep, 1)
    171         timestamp = baseconv.base62.decode(timestamp)
     171        timestamp = baseconv.base62.decode(timestamp) / 10000.0
    172172        if max_age is not None:
    173173            # Check timestamp is not older than max_age
    174174            age = time.time() - timestamp
Back to Top