1
0
Files
terraform.examples/modules/security_identity_compliance/LambdaAccessKey/client.tpl
T
2026-06-14 16:05:47 +08:00

24 lines
707 B
Smarty

#!/usr/bin/python3
import base64
import hashlib
import requests
def decrypt_data(encrypted_data: str) -> str:
key_hash = hashlib.sha256('${encryption_pass}'.encode()).digest()
encrypted_bytes = base64.b64decode(encrypted_data.encode())
decrypted = bytes(b ^ key_hash[i % len(key_hash)] for i, b in enumerate(encrypted_bytes))
return decrypted.decode()
url = "${cloudfront_url}"
try:
response = requests.get(url, timeout=10)
response.raise_for_status()
data = response.json()
print(decrypt_data(data['result']))
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}")
except Exception as err:
print(f"An error occurred: {err}")