Refactored code
This commit is contained in:
26
src_old/sh_edraft/utils/__init__.py
Normal file
26
src_old/sh_edraft/utils/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_edraft.utils
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
:copyright: (c) 2020 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'sh_edraft.utils'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||
__version__ = '2020.12.9'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
from .credential_manager import CredentialManager
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major=2020, minor=12, micro=9)
|
17
src_old/sh_edraft/utils/credential_manager.py
Normal file
17
src_old/sh_edraft/utils/credential_manager.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import base64
|
||||
|
||||
|
||||
class CredentialManager:
|
||||
|
||||
@staticmethod
|
||||
def encrypt(string: str) -> str:
|
||||
return base64.b64encode(string.encode('utf-8')).decode('utf-8')
|
||||
|
||||
@staticmethod
|
||||
def decrypt(string: str) -> str:
|
||||
return base64.b64decode(string).decode('utf-8')
|
||||
|
||||
@staticmethod
|
||||
def build_string(string: str, credentials: str):
|
||||
return string.replace('$credentials', CredentialManager.decrypt(credentials))
|
||||
|
Reference in New Issue
Block a user