Created
June 14, 2017 09:45
-
-
Save suryadana/cb12585ba8a667799ec252e56d89fa33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, zlib, gzip | |
def depress(str): | |
list_str = list(str) | |
list_str[0] = chr(ord(str[0]) ^ ord('E')) | |
str = ''.join(list_str) | |
z = str[0] | |
for x, y in enumerate(str[1:]): | |
z += chr(ord(y) ^ ord(z[x])) | |
return z | |
def decompress(str): | |
return zlib.decompress(depress(str)) | |
def ez(file): | |
with gzip.open(file, 'r') as x, open(file.replace(".EZip", ""), 'w') as y: | |
y.write(decompress(x.read())) | |
def main(): | |
try: | |
if len(sys.argv) == 2: | |
ez(sys.argv[1]) | |
else: | |
print """ | |
EEEE ZZZZZ | |
E Z ii | |
EEE Z ppp | |
E Z ii p p | |
EEEE ZZZZZ ii ppp | |
p | |
Encrypt and Zip | |
Usage: | |
python EZip.py file""" | |
except Exception as error: | |
print error | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment