Best Python code snippet using tox_python
encrypt.py
Source:encrypt.py
1from Crypto.Cipher import AES2import base643import utils4EncodedPartnerToken = 'pOwEMHkILj263JJxU150TaY4WLSrZrOg/5461micp0UnbDsyCOORiXGMmJSWRuAvPf/M75sLIsfzhJaCTsCUeg=='5EncodedMerchantToken = 'dSiUYs/Kj0EehSSIjxsyf1TrwKoFJHVLC+NIF1KCf0MhuVGGryW9YtuI7vxTyX4FesbguyDe/KllkbQ0IYlrcA=='6EncodedFromMail = 'WCFemY/IjrBxC8z2QybSmIpT/hpJcLtvNZyMsTADxl4='7EncodedToMail = 'KPCxI6QmV0baUkuQtX9HICjwsSOkJldG2lJLkLV/RyDBXYGC+/5UJai7Tn2/hQM0ZFMW9Me6x5AzkssoXfWWpg=='8EncodedGoogleAPI = 'KPCxI6QmV0baUkuQtX9HIFh0QM5YjEVyk5CvFQjnnFjz8l2whqRYS4rs53Zqw3omNQOurWBJFpr3Ts5vpzt+dg=='9EncodedCheck = 'KPCxI6QmV0baUkuQtX9HICjwsSOkJldG2lJLkLV/RyAo8LEjpCZXRtpSS5C1f0cgzw9nbTcmxhRFVkCnILyKhg=='10passdict = utils.readJson('../password.json')11if passdict == {}:12 password = raw_input("Password:")13else:14 password = passdict['password']15#Used once for generating encoded key paste above16def makeKey(p,Key):17 msg = Key.rjust(64)18 cipher = AES.new(key=p.rjust(32))19 enc = cipher.encrypt(msg)20 #print(enc)21 #print(cypher.decrypt(enc))22 encoded = base64.b64encode(enc)23 return encoded24def getDecoded(encoded):25 cipher = AES.new(key=password.rjust(32))26 decoded = cipher.decrypt(base64.b64decode(encoded))27 return decoded28def getPartnerToken():29 return getDecoded(EncodedPartnerToken)30def getMerchantToken():31 return getDecoded(EncodedMerchantToken)32def getFromMail():33 return getDecoded(EncodedFromMail)34def getToMail():35 return getDecoded(EncodedToMail).strip()36def getGoogleAPI():37 return getDecoded(EncodedGoogleAPI).strip()38def getCheck():39 return getDecoded(EncodedCheck).strip()40def checkPassword(attempt):41 cipher = AES.new(key=attempt.rjust(32))42 decoded = cipher.decrypt(base64.b64decode(EncodedCheck))43 if decoded.strip() == 'CodeCracked!':44 return True45 else:...
highValueClient.py
Source:highValueClient.py
1import socket2"""3 Our simple client for higher values4 Copyright (C) 2014 Leon Schwalb and Fabian Stein5 6 This program is free software: you can redistribute it and/or modify7 it under the terms of the GNU General Public License as published by8 the Free Software Foundation, either version 3 of the License, or9 (at your option) any later version.10 11 This program is distributed in the hope that it will be useful,12 but WITHOUT ANY WARRANTY; without even the implied warranty of13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 GNU General Public License for more details.15 16 You should have received a copy of the GNU General Public License17 along with this program. If not, see <http://www.gnu.org/licenses/>.18 """19def connect(host, port, message):20 21 finalString = " "22 23 connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)24 address = (host, port)25 26 connection.connect(address)27 28 connection.sendall(str.encode(message))29 while True:30 get = connection.recv(8192)31 getDecoded = get.decode("UTF-8")32 if getDecoded != "":33 getDecoded = str(getDecoded)34 print(getDecoded)35 else:36 break37 38 connection.close()39 ...
client.py
Source:client.py
1import socket2"""3Our simple client4Copyright (C) 2014 Leon Schwalb and Fabian Stein5This program is free software: you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation, either version 3 of the License, or8(at your option) any later version.9This program is distributed in the hope that it will be useful,10but WITHOUT ANY WARRANTY; without even the implied warranty of11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12GNU General Public License for more details.13You should have received a copy of the GNU General Public License14along with this program. If not, see <http://www.gnu.org/licenses/>.15"""16def connect(host, port, message):17 18 finalString = ""19 20 connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)21 address = (host, port)22 23 connection.connect(address)24 25 connection.sendall(str.encode(message))26 while True:27 get = connection.recv(8192)28 getDecoded = get.decode("UTF-8")29 if getDecoded != "":30 getDecoded = str(getDecoded)31 finalString += finalString + getDecoded32 else:33 break34 35 connection.close()36 ...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!