def create_key(self): self.count += 1 print self.count duration = datetime.datetime.now() - startTime # if duration.seconds == 5: # self.random_key = os.urandom(16) # crypto = AES.AESCipher(self.random_key) # # text = 'key:' + self.random_key # self.s.send(text) # print self.random_key while True: time.sleep(10) random_key = os.urandom(16) text = "key:" + random_key self.send(text) self.crypto = AES.AESCipher(random_key) print text return
def recv(self): while True: try: data = self.s.recv(1024) data = self.crypto.decrypt(data) textRecv = StringIO.StringIO(data) prin = textRecv.read(4) print prin if prin == 'key:': newKey = textRecv.read() self.crypto = AES.AESCipher(newKey) print newKey elif data: data = 'Other : ' + data + '\n' start = self.history.index('end') + "-1l" self.history.insert("end", data) end = self.history.index('end') + "-1l" self.history.tag_add("SENDBYOTHER", start, end) self.history.tag_config("SENDBYOTHER", foreground='green') except Exception as e: print(e, 'recv')
def __encrypt(self): password, ok = QtGui.QInputDialog.getText(self.MainWindow, "Encrypt", "Password:"******"utf-8")) return True except UnicodeError as error: logger.error(error) QtGui.QMessageBox.critical( self.MainWindow, "Message", "I can encrypt only ascii" " characters") except Exception as error: logger.error(error) QtGui.QMessageBox.critical(self.MainWindow, "Message", str(error)) return False
def get_config(self): # load configuration print("Enter configuration file:") enc_config_file = input() self.filename, _ = os.path.splitext(enc_config_file) try: with open(enc_config_file, "r") as f: encryptedconfig = f.read() try: print("Enter configuration password:"******"base64")) self.config = config except: print( "Reading configuration failed. Make sure the file is properly encrypted and you are using the correct password." ) except: print("Could not find configuration file")
def __decrypt(self): password, ok = QtGui.QInputDialog.getText(self.MainWindow, "Decrypt", "Password:"******"utf-8")) return True except UnicodeError as error: logger.error(error) QtGui.QMessageBox.critical(self.MainWindow, "Message", "Wrong password!") self.decrypt() except Exception as error: logger.error(error) QtGui.QMessageBox.critical(self.MainWindow, "Message", str(error)) return False
def __init__(self): self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print("[+] Socket Is Now Created") self.crypto = AES.AESCipher('mysecretpassword')
def __init__(self): self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.count = 0 self.crypto = AES.AESCipher('mysecretpassword')
print("Sell cap:") config["sell-cap"] = input() # 200 print("Buy cap:") config["buy-cap"] = input() # 200 print("Polling time in seconds:") config["polling-time"] = input() # 120 print("E-mail address for notifications:") config["mail-notification"] = input() #print("Use PGP (Y/N)") #config["PGP"] = True if input() == "Y" else False config["timestamp"] = str(datetime.now()) create_db(filename) # bitvavo kay and secret: print("Enter bitvavo API key") config["bitvavokey"] = getpass.getpass() print("Enter bitvavo API secret") config["bitvavosecret"] = getpass.getpass() # serialize object and convert is to base 64 string pickledconfig_b64 = codecs.encode(pickle.dumps(config), "base64").decode() # encrypt bytes print("Configuration password:"******".enc", "w") as f: f.write(encryptedconfig.decode())