def decrypt_api_key(key): try: server_key = fernet_decrypt(key) if key else None except Exception as e: LOG.exception(e) server_key = None return server_key
def get_hypanel_server_settings(server: Server): decrypted_password = fernet_decrypt(server.settings['password']) return { 'url': server.settings['url'], 'username': server.settings['username'], 'password': decrypted_password }
def to_representation(self, value): if value: try: value = fernet_decrypt(value) except Exception as e: LOG.exception(e) value = None return super(HypanelPasswordSerializer, self).to_representation(value)
def refresh_license(request): try: key = Option.objects.get(section='LICENSE', field='key') license_key = fernet_decrypt(key.value) except Option.DoesNotExist as e: LOG.error(e) raise ObjectNotFound(detail=_('License not found')) else: try: response, status = _set_license(license_key) return Response({'detail': response}, status=status) except requests.ConnectionError as e: LOG.error(e) raise ServiceUnavailable( detail=_('Can\'t connect to server. ' 'Please check your internet connection and retry.'))
def get_license_key(q): """Get already set license key.""" try: key = Option.objects.get(section='LICENSE', field='key') license_key = fernet_decrypt(key.value) LOG.info('License key: {}'.format(license_key)) q.put(license_key) except Option.DoesNotExist: try: from fleio.core import loginview license_info = json.loads(loginview.get_license_info()) license_key = license_info['License key'] LOG.info('License key: {}'.format(license_key)) q.put(license_key) except ImportError as e: LOG.error(e) q.put(None) return None
def get_secret_key(self): return fernet_decrypt(self.secret_key)
def get_secret_data(self) -> dict: return dict( stripe_customer_id=fernet_decrypt(self.stripe_customer_id), stripe_payment_method=fernet_decrypt(self.stripe_payment_method), )
def get_secret_data(self) -> dict: return dict( token_hash=fernet_decrypt(self.token_hash), ipn_cc_mask=fernet_decrypt(self.ipn_cc_mask) if self.ipn_cc_mask else None, ipn_cc_exp_date=fernet_decrypt(self.ipn_cc_exp_date) if self.ipn_cc_exp_date else None, )
def decode_epp_code(epp_code): if epp_code is None: return None return fernet_decrypt(epp_code)