def DecryptHash(key, ciphertext): """Decrypt a hash with a private key.""" encrypted = base64.b64decode(ciphertext) plaintext = key.decrypt(compat.stringToBytes(encrypted)) if plaintext: return compat.bytesToString(plaintext) else: # decryption failed return None
def filter(packetNo, data, source, target): bytes = stringToBytes(data) if packetNo == 0 and 'Client2Server' in str(source): pass elif packetNo == 1 and 'Client2Server' not in str(source): print "server says hello" print bytes result = bytesToString(bytes) target.write(result) return result