26 lines
547 B
Python
26 lines
547 B
Python
|
|
import base64
|
||
|
|
from Crypto.Util.number import *
|
||
|
|
from pwntools import xor
|
||
|
|
|
||
|
|
|
||
|
|
# Challenge intro-1
|
||
|
|
def int_to_ascii(input: [int]) -> str:
|
||
|
|
res = bytearray()
|
||
|
|
for i in input:
|
||
|
|
res += i.to_bytes()
|
||
|
|
return res.decode("utf-8")
|
||
|
|
|
||
|
|
|
||
|
|
# Challenge intro-2
|
||
|
|
def hex_to_ascii(input: str) -> str:
|
||
|
|
return bytes.fromhex(input).decode("utf-8")
|
||
|
|
|
||
|
|
|
||
|
|
# Challenge intro-3
|
||
|
|
def hex_to_b64(input: str) -> bytes:
|
||
|
|
return base64.b64encode(bytes.fromhex(input))
|
||
|
|
|
||
|
|
|
||
|
|
# Challenge intro-4
|
||
|
|
def int_to_message_rsa(input: int) -> str:
|
||
|
|
return long_to_bytes(input)
|