Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import struct
- import sys
- def bytes_to_long(s):
- """Convert a byte string to a long integer (big endian).
- In Python 3.2+, use the native method instead::
- >>> int.from_bytes(s, 'big')
- For instance::
- >>> int.from_bytes(b'\x00P', 'big')
- 80
- This is (essentially) the inverse of :func:`long_to_bytes`.
- """
- acc = 0
- unpack = struct.unpack
- # Up to Python 2.7.4, struct.unpack can't work with bytearrays nor
- # memoryviews
- if sys.version_info[0:3] < (2, 7, 4):
- if isinstance(s, bytearray):
- s = bytes(s)
- elif isinstance(s, memoryview):
- s = s.tobytes()
- length = len(s)
- if length % 4:
- extra = (4 - length % 4)
- s = b'\x00' * extra + s
- length = length + extra
- for i in range(0, length, 4):
- acc = (acc << 32) + unpack('>I', s[i:i+4])[0]
- return acc
- e = 17
- flag = "filler message go"
- e = 17
- n = 87248236976292375831726524431741785684972318062285568616700095704226943370108008367080490127391268247316969228948667432993586517883882862389422353850807246052106105023616135029870486239184167566566665353806935571175060912579679657097275204196999279619131945599336000635277556410739489817981698414802508845879
- def prepare(message):
- return bytes_to_long(message.encode('utf-8'))
- i = 0
- def set_seed():
- i = random.randint(1, n)
- set_seed()
- for i in range(1, 5):
- new_flag = flag + str(i)
- print(prepare(new_flag))
- ct = pow(prepare(new_flag), e, n)
- print(f'{ct = }')
- set_seed()
- print(f'{n = }')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement