Skip to content

Instantly share code, notes, and snippets.

View GordonOus's full-sized avatar

GordonOus

View GitHub Profile
ssh-keygen -e -f 'bruce_rsa_6e7ecd53b443a97013397b1a1ea30e14.pub' -m 'PKCS8' > bruce.pub
openssl rsa -pubin -in bruce.pub -noout -modulus | cut -d '=' -f2 | xargs echo "ibase=16; $1"| bc | tr -d '\' | tr -d '\n'
@GordonOus
GordonOus / diffusion_permutation.py
Created September 25, 2021 18:13
cryptohack symmetric crypto series
def shift_rows(s):
s[0][1], s[1][1], s[2][1], s[3][1] = s[1][1], s[2][1], s[3][1], s[0][1]
s[0][2], s[1][2], s[2][2], s[3][2] = s[2][2], s[3][2], s[0][2], s[1][2]
s[0][3], s[1][3], s[2][3], s[3][3] = s[3][3], s[0][3], s[1][3], s[2][3]
def inv_shift_rows(s):
tmp = s[13]
s[13] = s[9]
s[9] = s[5]
@GordonOus
GordonOus / adrien_sign.py
Created October 4, 2021 14:13
cryptohack adrien_signs
def pohligHellmanPGH(p,g,h):
#p is the modulus
#g is the argument (a)
#h is the equivalence class i.e the result of pow(g,e,p). e is what we are looking for
F=IntegerModRing(p)
g=F(g)
h=F(h)
G=[]
H=[]
X=[]
import math
from random import randint, seed
from time import time, process_time
import string
strchr = lambda x: chr(x)
strbyt = lambda x, y=0: ord(x[y])
bitlst = lambda x, y: x << y
bitrst = lambda x, y: x >> y
bitext = lambda x, y, z=1: bitrst(x, y) & int(math.pow(2, z) - 1)