Skip to content

Instantly share code, notes, and snippets.

@Nircek
Created October 3, 2018 17:25
Show Gist options
  • Select an option

  • Save Nircek/f5619f52c85a17453ca83b7884f2be73 to your computer and use it in GitHub Desktop.

Select an option

Save Nircek/f5619f52c85a17453ca83b7884f2be73 to your computer and use it in GitHub Desktop.
SUBcipher
#!/usr/bin/env python3
a=open('in.txt', 'rb').read()
d = 0
e = b''
for i in a:
if d > i:
d -= 256
e += bytes([i-d])
d = i
open('out.bin', 'wb').write(e)
#!/usr/bin/env python3
a = open('out.bin', 'rb').read()
c = bytes([a[0]])
for i in range(1,len(a)):
print(a[i], c[i-1], sep='\t')
c += bytes([(c[i-1]+a[i])%256])
b = open('out.txt', 'wb').write(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment