Advertisement
Guest User

Untitled

a guest
Jan 10th, 2025
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import random
  2. import struct
  3. import sys
  4.  
  5. def bytes_to_long(s):
  6. """Convert a byte string to a long integer (big endian).
  7.  
  8. In Python 3.2+, use the native method instead::
  9.  
  10. >>> int.from_bytes(s, 'big')
  11.  
  12. For instance::
  13.  
  14. >>> int.from_bytes(b'\x00P', 'big')
  15. 80
  16.  
  17. This is (essentially) the inverse of :func:`long_to_bytes`.
  18. """
  19. acc = 0
  20.  
  21. unpack = struct.unpack
  22.  
  23. # Up to Python 2.7.4, struct.unpack can't work with bytearrays nor
  24. # memoryviews
  25. if sys.version_info[0:3] < (2, 7, 4):
  26. if isinstance(s, bytearray):
  27. s = bytes(s)
  28. elif isinstance(s, memoryview):
  29. s = s.tobytes()
  30.  
  31. length = len(s)
  32. if length % 4:
  33. extra = (4 - length % 4)
  34. s = b'\x00' * extra + s
  35. length = length + extra
  36. for i in range(0, length, 4):
  37. acc = (acc << 32) + unpack('>I', s[i:i+4])[0]
  38. return acc
  39. e = 17
  40.  
  41. flag = "filler message go"
  42. e = 17
  43. n = 87248236976292375831726524431741785684972318062285568616700095704226943370108008367080490127391268247316969228948667432993586517883882862389422353850807246052106105023616135029870486239184167566566665353806935571175060912579679657097275204196999279619131945599336000635277556410739489817981698414802508845879
  44.  
  45. def prepare(message):
  46. return bytes_to_long(message.encode('utf-8'))
  47.  
  48. i = 0
  49.  
  50. def set_seed():
  51. i = random.randint(1, n)
  52.  
  53. set_seed()
  54.  
  55. for i in range(1, 5):
  56. new_flag = flag + str(i)
  57. print(prepare(new_flag))
  58. ct = pow(prepare(new_flag), e, n)
  59. print(f'{ct = }')
  60. set_seed()
  61.  
  62. print(f'{n = }')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement