Skip to content

Instantly share code, notes, and snippets.

@AndyNovo

AndyNovo/algy.py Secret

Last active March 6, 2019 17:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AndyNovo/b9b303337b04f38f092766e19715d036 to your computer and use it in GitHub Desktop.
# Python 2.7
from Crypto.Util.number import *
f=file('flag','r')
theflag = f.read()
f.close()
p=257
key = getRandomRange(3,p-3)
def encrypt(pt, key, p):
bytearray=[]
for ltr in pt:
bytearray.append(key*inverse(ord(ltr), p) % p)
return "".join(map(chr, bytearray))
ct = encrypt(theflag.strip(), key, p)
f=file('ciphertext','w')
f.write(ct.encode('hex'))
f.close()
d2dcd257d1a90ea0a067a2dbcfa246a2dbcfe7bca2db04a2a0b3d2a2cf0e6b4bc787cf8d3ea23e87048ed0a052
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment