Example #1
0
    def to_timestamp(value):
        """
        Return URL safe base62 encoded timestamp of given datetime.

        Args:
            value (datetime.datetime): Datetime instance to encode.

        Returns:
            str: URL safe base62 encoded timestamp.

        """
        if value is None:
            return ""
        return signing.b62_encode(int(value.timestamp()))
Example #2
0
 def test_base62(self):
     tests = [-10**10, 10**10, 1620378259, *range(-100, 100)]
     for i in tests:
         self.assertEqual(i, signing.b62_decode(signing.b62_encode(i)))
Example #3
0
 def _make_hash_value(self, user):
     last_login = self.to_timestamp(user.last_login)
     user_pk = signing.b62_encode(user.pk)
     return self.sep.join((user_pk, last_login))