-
-
Save AndyNovo/615e64d30d2a48b49497b8a19f93fd21 to your computer and use it in GitHub Desktop.
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
#This AWS lambda is setup at: | |
#https://o5lyi532hb.execute-api.us-east-1.amazonaws.com/default/ecboracle?prefixhex=00112233 | |
import json | |
import os | |
import sys | |
from Crypto.Cipher import AES | |
from Crypto.Util.Padding import pad, unpad | |
def lambda_handler(event, context): | |
prefix=bytes.fromhex(event["queryStringParameters"]["prefixhex"]) | |
flag = os.environ["flag"] | |
padded = pad(prefix + flag.encode(), 16) | |
cipher = AES.new(os.environ["secretkey"].encode(), AES.MODE_ECB) | |
try: | |
encrypted = cipher.encrypt(padded) | |
except ValueError as e: | |
return {'statusCode': 500, "error": str(e)} | |
return { | |
'statusCode': 200, | |
'body': json.dumps({"ciphertext": encrypted.hex()}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment