pgcontents/crypto.py
def derive_fallback_fernet_keys(passwords, user_id):
    """
    Derive a list of per-user Fernet keys from a list of master keys and a
    username.

    If a None is encountered in ``passwords``, it is forwarded.

    Parameters
    ----------
    passwords : list[unicode]
        List of ascii-encodable keys to derive.
    user_id : unicode or None
        ascii-encodable user_id to use as salt
    """
    # Normally I wouldn't advocate for these kinds of assertions, but we really
    # really really don't want to mess up deriving encryption keys.
    assert isinstance(passwords, (list, tuple)), \
        "Expected list or tuple of keys, got %s." % type(passwords)

    def derive_single_allow_none(k):
        if k is None:
            return None
        return derive_single_fernet_key(k, user_id).decode('ascii')

    return list(map(derive_single_allow_none, passwords))
def derive_fallback_fernet_keys(passwords, user_id):
    # Normally I wouldn't advocate for these kinds of assertions, but we really
    # really really don't want to mess up deriving encryption keys.
    assert isinstance(passwords, (list, tuple)), \
        "Expected list or tuple of keys, got %s." % type(passwords)

    def derive_single_allow_none(k):
        if k is None:
            return None
        return derive_single_fernet_key(k, user_id).decode('ascii')

    return list(map(derive_single_allow_none, passwords))
def derive_fallback_fernet_keys ( passwords , user_id ) : # Normally I wouldn't advocate for these kinds of assertions, but we really # really really don't want to mess up deriving encryption keys. assert isinstance ( passwords , ( list , tuple ) ) , "Expected list or tuple of keys, got %s." % type ( passwords ) def derive_single_allow_none ( k ) : if k is None : return None return derive_single_fernet_key ( k , user_id ) . decode ( 'ascii' ) return list ( map ( derive_single_allow_none , passwords ) )
Derive a list of per-user Fernet keys from a list of master keys and a
    username.

    If a None is encountered in ``passwords``, it is forwarded.

    Parameters
    ----------
    passwords : list[unicode]
        List of ascii-encodable keys to derive.
    user_id : unicode or None
        ascii-encodable user_id to use as salt
Derive a list of per - user Fernet keys from a list of master keys and a username .