def gcd(m, n):
if m < n:
m,n = n, m
if n == 0:
return m
if m % n == 0:
return n
else:
return gcd(n, m%n)
def main():
print(gcd(66528, 52920))
if __name__ == "__main__":
main()
def gcd(m,n):
while n != 0:
r = m%n
(m,n) = (n,r)
return abs(m)
def main():
print(gcd(66528, 52920))
if __name__ == "__main__":
main()
def extended_gcd(a, b):
if b > a:
a, b = b, a
if b == 0:
return 0, 1
r = a % b
print("a:{}, b:{}, r:{}".format(a, b, r))
v, u = extended_gcd(r, b)
print("exit - a:{}, b:{}, v:{}, u:{}, r:{}".format(a, b, v, u, r))
return u - (a//b) * v, v
def main():
u, v = extended_gcd(26513, 32321)
print("{}, {}".format(u, v))
if __name__ == "__main__":
main()
#!/usr/bin/env python3
import sys
# import this
if sys.version_info.major == 2:
print("You are running Python 2, which is no longer supported. Please update to Python 3.")
ords = [81, 64, 75, 66, 70, 93, 73, 72, 1, 92, 109, 2, 84, 109, 66, 75, 70, 90, 2, 92, 79]
print("Here is your flag:")
print("".join(chr(o ^ 0x32) for o in ords))
import binascii
a = '73626960647f6b206821204f21254f7d694f7624662065622127234f726927756d'
result=''
a = binascii.unhexlify(a)
for c in a:
result += chr(c^(a[0]^ord('c')))
print(result)
import binascii
from Crypto.Util.strxor import *
a = '0e0b213f26041e480b26217f27342e175d0e070a3c5b103e2526217f27342e175d0e077e263451150104'
key=''
result =''
# key 획득 및 유추
a = binascii.unhexlify(a)
key = strxor((a[:7]), b'crypto{')
# xor 연산
key = list('myXORkey')
for i in range(len(a)):
result += chr(a[i] ^ ord(key[i%8]))
print(result)