當前位置: 首頁>>代碼示例>>Python>>正文


Python fernet.MultiFernet方法代碼示例

本文整理匯總了Python中cryptography.fernet.MultiFernet方法的典型用法代碼示例。如果您正苦於以下問題:Python fernet.MultiFernet方法的具體用法?Python fernet.MultiFernet怎麽用?Python fernet.MultiFernet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cryptography.fernet的用法示例。


在下文中一共展示了fernet.MultiFernet方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_fernet

# 需要導入模塊: from cryptography import fernet [as 別名]
# 或者: from cryptography.fernet import MultiFernet [as 別名]
def get_fernet():
    """
    Deferred load of Fernet key.

    This function could fail either because Cryptography is not installed
    or because the Fernet key is invalid.

    :return: Fernet object
    :raises: airflow.exceptions.AirflowException if there's a problem trying to load Fernet
    """
    global _fernet

    if _fernet:
        return _fernet

    try:
        fernet_key = conf.get('core', 'FERNET_KEY')
        if not fernet_key:
            log.warning(
                "empty cryptography key - values will not be stored encrypted."
            )
            _fernet = NullFernet()
        else:
            _fernet = MultiFernet([
                Fernet(fernet_part.encode('utf-8'))
                for fernet_part in fernet_key.split(',')
            ])
            _fernet.is_encrypted = True
    except (ValueError, TypeError) as ve:
        raise AirflowException("Could not create Fernet object: {}".format(ve))

    return _fernet 
開發者ID:apache,項目名稱:airflow,代碼行數:34,代碼來源:crypto.py

示例2: __attrs_post_init__

# 需要導入模塊: from cryptography import fernet [as 別名]
# 或者: from cryptography.fernet import MultiFernet [as 別名]
def __attrs_post_init__(self):
        """Initialize the Settings object"""
        # Setup hosts/ports/urls
        if not self.hostname:
            self.hostname = socket.gethostname()
        if self._resolve_hostname:
            self.hostname = resolve_ip(self.hostname)

        if not self.endpoint_hostname:
            self.endpoint_hostname = self.hostname
        if not self.router_hostname:
            self.router_hostname = self.hostname

        self.router_url = canonical_url(
            self.router_scheme or 'http',
            self.router_hostname,
            self.router_port
        )
        self.endpoint_url = canonical_url(
            self.endpoint_scheme or 'http',
            self.endpoint_hostname,
            self.endpoint_port
        )
        # not accurate under autoendpoint (like router_url)
        self.ws_url = "{}://{}:{}/".format(
            'wss' if self.ssl.key else 'ws',
            self.hostname,
            self.port
        )

        self.fernet = MultiFernet([Fernet(key) for key in self._crypto_key]) 
開發者ID:mozilla-services,項目名稱:autopush,代碼行數:33,代碼來源:config.py

示例3: fernet

# 需要導入模塊: from cryptography import fernet [as 別名]
# 或者: from cryptography.fernet import MultiFernet [as 別名]
def fernet(self):
        if len(self.fernet_keys) == 1:
            return Fernet(self.fernet_keys[0])
        return MultiFernet([Fernet(k) for k in self.fernet_keys]) 
開發者ID:orcasgit,項目名稱:django-fernet-fields,代碼行數:6,代碼來源:fields.py


注:本文中的cryptography.fernet.MultiFernet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。