本文整理汇总了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])