Package: cypher-protocol-P-Y-R-O-B-O-T
CYPHER_PROTOCOLPROJECT LINK GITHUBPROJECT LINK PYPIThis is a type of communication protocol made for computers using TCP sockets.This is a highly secure and trust worthy protocol made using tcp sockets. It uses aggressively secure encryption AES-128 bit algorithm both the ways for a tight securityISSUES WITH OTHER PROTOCOLSOther protocols give errors when some error occurs and we have to handle it manually to remove it or to continue the process in the same sequence but CYPHER_PROTOCOL does that error handling automatically and the programmers are more free to focus on the flow instead of error handling.Whenever some error occurs in recieving data or sending data it resolves it automatically.Whenever it notices a disconnection from server it automatically re-connects to the server.COMPATIBLITYCYPHER_PROTOCOL works with Linux, OS-X, and Windows (OS INDEPENDENT).But it may give better experience on linux.INSTALLATIONInstall it using pip.GotoPYPIHOW TO USE ?Encryption key is a 32 character encryption key for the server and decryption key for clientDecryption key is a 32 character decryption key for server and encryption key for the clientAlthough encryption and decryption key can be kept same for any reasonrequest_processor in server initialisation is a method/function that user have to define and it is used to process the request recieved from clientresponce_processor in client initialisation is a method/function that user have to define and it is used to process the responce recieved from serverServer's request handler recieves the request in the form :{
"PATH": str,
"OPERATION": str,
"DATA": YOUR_DATA_HERE,
"METADATA": dict
}But it can also be modified as per needs"PATH" is like the path we see in http protocol and here it is "/" by default"OPERATION" is operation we have to perform like "UPDATE", "DELETE", "READ", "CREATE" etc. Also you can create your own type of operation if you want to, its just for convenience"DATA" contains data that you want to share between the server and the client"METADATA" contains data that you may need to use, its completely optionalSERVERimporttimeimporttracebackfromCYPHER_PROTOCOL.CYPHER_SERVER.cypher_serverimportCYPHER_SERVERSEQUENCE=[]NUMBER=0defrequest_processor(data:dict,ip_port:tuple)->dict:globalSEQUENCEglobalNUMBERprint(data)ifdata["PATH"]=="/SEQUENCE":ifdata["OPERATION"]=="UPDATE":SEQUENCE.append(data["DATA"])iflen(SEQUENCE)>10:SEQUENCE.pop(0)responce={"PATH":data["PATH"],"OPERATION":data["OPERATION"],"METADATA":data["METADATA"]}responce["DATA"]="UPDATED"returnresponceelifdata["OPERATION"]=="READ":responce={"PATH":data["PATH"],"OPERATION":data["OPERATION"],"METADATA":data["METADATA"]}responce["DATA"]=SEQUENCEreturnresponceelifdata["PATH"]=="/NUMBER":ifdata["OPERATION"]=="UPDATE":NUMBER=data["DATA"]responce={"PATH":data["PATH"],"OPERATION":data["OPERATION"],"METADATA":data["METADATA"]}responce["DATA"]="UPDATED"returnresponceelifdata["OPERATION"]=="READ":responce={"PATH":data["PATH"],"OPERATION":data["OPERATION"],"METADATA":data["METADATA"]}responce["DATA"]=NUMBERreturnresponceSERVER_OBJECT=CYPHER_SERVER(host="",port=12345,encryption_key="2ZpK1CdQfm0s1EZ1SIhYfV7MHdJf8X3U",decryption_key="2ZpK1CdQfm0s1EZ1SIhYfV7MHdJf8X3U",request_handler=request_processor,recv_buffer=1024*1024*8,tranamission_buffer=1024*1024*2,timeout=120,debug1=True,debug2=True)SERVER_OBJECT.start_server()input()SERVER_OBJECT.stop_server()CLIENTimportthreadingimporttimeimportrandomfromCYPHER_PROTOCOL.CYPHER_CLIENT.cypher_clientimportCYPHER_CLIENTdefresponce_processor(responce:dict):print(responce)defonline_sig_processor():print("You are online")defoffline_sig_processor():print("You are offline")defrequest_maker():globalCLIENT_OBJECTwhileTrue:request={"PATH":"/SEQUENCE","OPERATION":"UPDATE","DATA":random.randint(0,1000),"METADATA":{}}CLIENT_OBJECT.make_request(path=request["PATH"],operation=request["OPERATION"],data=request["DATA"],metadata=request["METADATA"])time.sleep(1)request={"PATH":"/SEQUENCE","OPERATION":"READ","METADATA":{}}CLIENT_OBJECT.make_request(path=request["PATH"],operation=request["OPERATION"],metadata=request["METADATA"])#$$$$$$$$$$#request={"PATH":"/NUMBER","OPERATION":"UPDATE","DATA":random.randint(0,1000),"METADATA":{}}CLIENT_OBJECT.make_request(path=request["PATH"],operation=request["OPERATION"],data=request["DATA"],metadata=request["METADATA"])time.sleep(1)request={"PATH":"/NUMBER","OPERATION":"READ","METADATA":{}}CLIENT_OBJECT.make_request(path=request["PATH"],operation=request["OPERATION"],metadata=request["METADATA"])CLIENT_OBJECT=CYPHER_CLIENT(ip="127.0.0.1",port=12345,encryption_key="2ZpK1CdQfm0s1EZ1SIhYfV7MHdJf8X3U",decryption_key="2ZpK1CdQfm0s1EZ1SIhYfV7MHdJf8X3U",responce_handler=responce_processor,offline_signal_processor=offline_sig_processor,online_signal_processor=online_sig_processor,recv_buffer=1024*1024*8,tranamission_buffer=1024*1024*2,timeout=60)CLIENT_OBJECT.connect()THREAD=threading.Thread(target=request_maker,args=())THREAD.start()FTP SERVER & CLIENTNow FTP has also been implemented using CYPHER, the usage is similar to normal CYPHER implementations.Refer TEST_SCRIPTS/FTP_TEST for usage of FTP implementation.