paijo77 commited on
Commit
d11d640
·
verified ·
1 Parent(s): 6f97aa6

update app/utils/base64_decoder.py

Browse files
Files changed (1) hide show
  1. app/utils/base64_decoder.py +18 -0
app/utils/base64_decoder.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import base64
2
+
3
+
4
+ class SubscriptionDecoder:
5
+ @staticmethod
6
+ def decode(encoded_content: str) -> str:
7
+ if not encoded_content:
8
+ return ""
9
+
10
+ try:
11
+ missing_padding = len(encoded_content) % 4
12
+ if missing_padding:
13
+ encoded_content += "=" * (4 - missing_padding)
14
+
15
+ decoded_bytes = base64.b64decode(encoded_content)
16
+ return decoded_bytes.decode("utf-8")
17
+ except Exception as e:
18
+ raise ValueError(f"Invalid base64 content: {e}")