# Path: shrubbery/utils/dt.py
# def timedelta_seconds(delta):
#     return delta.seconds + SECONDS_PER_DAY * delta.days


import time
import hashlib
import hmac
import base64
from datetime import timedelta
from functools import wraps
from django.conf import settings
from django.http import HttpResponseForbidden
from shrubbery.utils.dt import timedelta_seconds




class BadToken(Exception): pass
class TokenExpired(BadToken): pass
class InvalidSignature(BadToken): pass


class SignedTokenFactory(object):
    def __init__(self, secret=settings.SECRET_KEY, hash_length=26):
        self.secret = secret
        self.hash_length = hash_length
    
    def encode(self, data):
        return base64.urlsafe_b64encode(data).rstrip('=')
        

# Path: shrubbery/utils/dt.py
# def timedelta_seconds(delta):
#     return delta.seconds + SECONDS_PER_DAY * delta.days


# Path: shrubbery/utils/signed_tokens.py
import time
import hashlib
import hmac
import base64
from datetime import timedelta
from functools import wraps
from django.conf import settings
from django.http import HttpResponseForbidden
from shrubbery.utils.dt import timedelta_seconds





class BadToken(Exception): pass
class TokenExpired(BadToken): pass
class InvalidSignature(BadToken): pass


class SignedTokenFactory(object):
    def __init__(self, secret=settings.SECRET_KEY, hash_length=26):
        self.secret = secret
        self.hash_length = hash_length
    
    def encode(self, data):
        return base64.urlsafe_b64encode(data).rstrip('=')
        

    def decode(self, data):