def derive_signature(key, qs):
    """Derives the signature from the supplied query string using the key."""
    key, qs = (key or "", qs or "")
    return hmac.new(key.encode(), qs.encode(), hashlib.sha1).hexdigest()