forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
from itsdangerous.url_safe import URLSafeSerializer | ||
|
||
import json | ||
from aws_lambda_powertools.utilities._data_masking.provider import BaseProvider | ||
|
||
|
||
class MyCustomEncryption(BaseProvider): | ||
def __init__(self, secret): | ||
super().__init__() | ||
self.secret = URLSafeSerializer(secret) | ||
self.secret = secret | ||
|
||
def encrypt(self, data: str) -> str: | ||
if data is None: | ||
return data | ||
return self.secret.dumps(data) | ||
return json.dumps(data) | ||
|
||
def decrypt(self, data: str) -> str: | ||
if data is None: | ||
return data | ||
return self.secret.loads(data) | ||
return json.loads(data) |