#!/usr/bin/env python # visit http://tool.lu/pyc/ for more information import random import base64 import sys
defKeyGenerate(): random.seed(10) keyseed = '' for i in range(12): x = random.randint(32, 127) keyseed += chr(x) return base64.b64encode(keyseed.encode('utf-8')).decode('utf-8')
defenc(key, file): count = 0 f = open(file, 'rb') f1 = open('encrypted', 'wb') for now in f: for nowByte in now: newByte = nowByte ^ ord(key[count % len(key)]) count += 1 f1.write(bytes([ newByte]))
if __name__ == '__main__': key = KeyGenerate() enc(key, sys.argv[1])
defKeyGenerate(): random.seed(10) keyseed = '' for i in range(12): x = random.randint(32, 127) keyseed += chr(x) return base64.b64encode(keyseed.encode('utf-8')).decode('utf-8')
defdec(key): f = open('encrypted', 'rb') f1 = open('decrypted', 'wb') for now in f: for nowByte in now: newByte = nowByte ^ ord(key[count % len(key)]) count += 1 f1.write(bytes([newByte]))
if __name__ == '__main__': key = KeyGenerate() dec(key)