mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-07-09 13:36:00 +00:00
19 lines
498 B
Python
19 lines
498 B
Python
import base64
|
|
|
|
|
|
class BaseCrypto:
|
|
def encrypt(self, text):
|
|
return base64.urlsafe_b64encode(
|
|
self._encrypt(bytes(text, encoding='utf8'))
|
|
).decode('utf8')
|
|
|
|
def _encrypt(self, data: bytes) -> bytes:
|
|
raise NotImplementedError
|
|
|
|
def decrypt(self, text):
|
|
return self._decrypt(
|
|
base64.urlsafe_b64decode(bytes(text, encoding='utf8'))
|
|
).decode('utf8')
|
|
|
|
def _decrypt(self, data: bytes) -> bytes:
|
|
raise NotImplementedError |