def security(policy, app_secret):
    """
    Creates a valid signature and policy based on provided app secret and
    parameters
    ```python
    from filestack import Client, security

    # a policy requires at least an expiry
    policy = {'expiry': 56589012, 'call': ['read', 'store', 'pick']}
    sec = security(policy, 'APP_SECRET')

    client =  Client('API_KEY', security=sec)
    ```
    """
    validate(policy)
    policy_enc = base64.urlsafe_b64encode(json.dumps(policy).encode('utf-8'))

    signature = hmac.new(app_secret.encode('utf-8'),
                         policy_enc,
                         hashlib.sha256).hexdigest()

    return {'policy': policy_enc, 'signature': signature}
Creates a valid signature and policy based on provided app secret and
    parameters
    ```python
    from filestack import Client, security

    # a policy requires at least an expiry
    policy = {'expiry': 56589012, 'call': ['read', 'store', 'pick']}
    sec = security(policy, 'APP_SECRET')

    client =  Client('API_KEY', security=sec)
    ```