本文整理匯總了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
示例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])
示例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])