Package: ascii-chiper
ascii_chiperascii_chiperis a Python module for encrypting and decrypting strings, integers, and dictionaries using various encryption techniques. The module provides user-friendly and customizable encryption configurations to suit different use cases and levels of security.FeaturesAccepts strings, integers, floats, lists and dictionaries as input for encryptionSupports multiple encryption techniques, including swapping, XOR shifting, interleaving, rotation, XOR base, XOR addition, and interleaving with keyOffers pre-configured encryption configurations for quick useAllows users to create custom encryption configurationsInstallationTo install the ascii_chiper module, use pip:pip install ascii_chiperUsageThis module is designed to be simple and easy to use. To get started, import theChiperclass and initialize an instance of it. You can then use theencryptanddecryptmethods to encrypt and decrypt your data.Theencryptmethod takes the data to be encrypted, a base key, a length, and an encryption configuration as input. You can use one of the predefined encryption configurations or create your own custom configuration. Thedecryptmethod requires the encrypted data, base key, length, and the same encryption configuration used during encryption.Hello Worldfromascii_chiperimportChiper# Initialize the Chiperchiper=Chiper(123)encrypted=chiper.encrypt("Hello World!",113,40,Chiper.BASIC_SWAP_INTERLEAVE)print(f"Encrypted:{encrypted}")# Output 'xSJJSHNlQWyubF1vDyClV7RvfnKobCZkzyGUIg=='decrypted=chiper.decrypt(encrypted)print(f"Decrypted:{decrypted}")# Output 'Hello World!'Basic usagefromascii_chiperimportChiper# Initialize the Chiperchiper=Chiper.initialize()# Encrypt a message using a default encryption configurationmessage="This is a test message."base,length=123456789,5encrypted_message=chiper.encrypt(message,base,length,encrypt_steps=Chiper.XORBASE_ROTATE)# Decrypt the encrypted messagedecrypted_message=chiper.decrypt(encrypted_message)print("Original message:",message)print("Encrypted message:",encrypted_message)print("Decrypted message:",decrypted_message)Custom configurationfromascii_chiperimportChiper,EncryptionModel,DecryptionModel# Initialize the Chiperchiper=Chiper.initialize()# Encrypt a message using a custom encryption configurationmessage="A custom encryption example."base,length=987654321,92custom_config=[{"interleave":{}},{"swap":{}},{"rotate":{"index":5}},{"xor_base":{"base":137,"start":0}},]encrypted_message=chiper.encrypt(message,base,length,encrypt_steps=custom_config)# Decrypt the encrypted message using a DecryptionModeldecryption_model=DecryptionModel.from_encryption_model(EncryptionModel(base,length,custom_config))decrypted_message=chiper.decrypt(encrypted_message,model=decryption_model)print("Original message:",message)print("Encrypted message:",encrypted_message)print("Decrypted message:",decrypted_message)Advanced usagefromascii_chiperimportChiper,KeyGenerator,\EncryptionModel,DecryptionModel# Custom encryption configurationcustom_config=[{"interleave":{}},{"rotate":{"index":2}},{"xor_add":{"start":0}},]# Create an encryption seed and modelseed=KeyGenerator.generate_seed()encryption_model=EncryptionModel(123456789,52,custom_config)# Encrypt a message using a custom encryption configurationmessage={"example":True,"message":"This is a test message."}encrypted_message=Chiper(seed).encrypt(message,model=encryption_model)# Decrypt the encrypted message using a DecryptionModeldecryption_model=DecryptionModel.from_encryption_model(encryption_model)decrypted_message=Chiper(seed).decrypt(encrypted_message,model=decryption_model)print("Original message:",message)print("Encrypted message:",encrypted_message)print("Decrypted message:",decrypted_message)Custom configuration with lambda functionsfromascii_chiperimportChiper,EncryptionModel,DecryptionModel# Initialize the Chiperchiper=Chiper.initialize()# Encrypt a message using a custom encryption configurationmessage="A custom encryption example."base,length=987654321,92custom_config=[{"swap":{}},{"rotate":{# We can use a lambda function to define the index# the len of the key is passed as the first argument"index":lambdakey:key%5,}},{"xor_base":{"base":137,# We can use predefined functions as well"start":Chiper.MIDDLE_OF_KEY,"end":Chiper.PENULTIMATE_OF_KEY,}},]encrypted_message=chiper.encrypt(message,base,length,encrypt_steps=custom_config)# Decrypt the encrypted message using a DecryptionModeldecryption_model=DecryptionModel.from_encryption_model(EncryptionModel(base,length,custom_config))decrypted_message=chiper.decrypt(encrypted_message,model=decryption_model)print("Original message:",message)print("Encrypted message:",encrypted_message)print("Decrypted message:",decrypted_message)Decrypt message by knowing key and stepsfromascii_chiperimportChiper,EncryptionModel,DecryptionModel# Decrypt a message using a custom encryption configurationencrypted="2tqBEWERKhGjI3qxKsFLuaMbWhNaybG5s5IqkmrKapJyyypDm6IqklrBmrlrWSq5WyuBkmrKymJqoZoTarErYqOBG6l6yyoiaqLKkqOqOhNaU3paq9ObE5ODKpqTy1pSq4taQ2Oxm1qryyvDe4NrC0q6qwtbWYGLMpIqYnILW9ObyxtiY5FKU3KhaoOrgavTq8taoptZEZJh6hHaEYkRYSMqsaPBerkqG0sTo8lauVqSsZKzyiqSastqQ3KiKpKbwSq5WlmauWsrKpJbmoFTq8F7InqiK1NqksoTMqIqYlLDehOLg0u5e7kqUmKLgYuby1pag5p7g6uTKwtqupsLWqmri1tDOoNCIyrTMsuaU6upG1NyoRqDcstq03qaC2KjuVqSm1lb6ZvqEdphCxGDg0tjCxtLo3N7g3kzI2ERKhGjI3qxKsFLuaMbWhNaybG5s5IqkmrKapJyyypDm6IqklrBmrlrWSq5WyuBkmrKymJqoZoTarErYqOBG6l6yyoiaqLKkqOqOhNaU3paq9ObE5ODKpqTy1pSq4taQ2Oxm1qryyvDe4NrC0q6qwtbWYGLMpIqYnILW9ObyxtiY5FKU3KhaoOrgavTq8taoptZEZJh6hHaK6Ojw4N5MyNhESoRoyN6sSrBS7mjG1oTWsmxubOSKpJqymqScssqQ5uiKpJawZq5a1kquVsrgZKrmntTesErImqiylMykioTUqJ6YovDSxN7gyq5YrmBUpuLWouDy3taq5org2qTmwtauqsLW6k6i0JDKoMyI5rTq8sbU3KpGlNyoWqDessL06OaWmKbuVuSm1kR6erq"used_encrypt_steps=[{"swap":{}},{"xor_shift":{}}]used_key=[114,114]excepted_output=[["0","Edt6O8E7ictbK9K76RvREYMRMyNhETsRE8K7S+m7EekR0YMLY4MbS6MLe0t5cyODETMRYUtbGjKKOzubsprSEyrJKquhK6lKsyuxepoamWIau+kq0RFLEaNzkysLc2ljI4NpM0uzuyuTK+sR"],["1","Edt6O8E7ictbK9K76RvREYMRMyNhETsRE8K7S+m7EekR0Sujo8ODeTMjYRFbETJLOxqbipo7E7LJ0qsqKypKoSuperMasWKau5kqGhHpEdFzSyujc5NjC4NpMyOzaStLK7sRk+s="],["application/pdf","Edt6O8E7ictbK9K76RvREYMRMyNhETsRE8K7S+m7EekR0YMLY4MbS6MLe0t5cyODETMRYUtbGjKKOzubsprSEyrJKquhK6lKsyuxepoamWIau+kq0RFLEaNzkysLc2ljI4NpM0uzuyuTK+sR"],["text/pdf","Edt6O8E7ictbK9K76RvREYMRMyNhETsRE8K7S+m7EekR0Sujo8ODeTMjYRFbETJLOxqbipo7E7LJ0qsqKypKoSuperMasWKau5kqGhHpEdFzSyujc5NjC4NpMyOzaStLK7sRk+s="]]# Create the EncryptionModelenc_model=EncryptionModel(0,0,encrypt_steps=used_encrypt_steps)# Initialize the Chiperchiper=Chiper.initialize()# Decrypt the encrypted messagedecrypted_message=chiper.decrypt(encrypted,key=used_key,decrypt_steps=DecryptionModel.from_encryption_model(enc_model).decrypt_steps)print("Decrypted message:",decrypted_message)print(f"Decrypted message is equal to excepted output:{decrypted_message==excepted_output}")# Have fun :P those looks like some mime_types encryptedFor other examples usages, please refer to the Examples folder.Encryption Methodsascii_chiperoffers various encryption techniques that can be combined in different configurations to achieve the desired level of security:NameDescriptionOptional ParametersreverseReverse the input data.swapSwaps pairs of characters in the input data.rotateRotates the input data by a specified index from the key.Index from key to useinterleaveInterleaves the input data, effectively rearranging the characters.key start/endinterleave_keyInterleaves the input data based on the key start and end positions.key start/endxor_shiftApplies an XOR shift operation using a specified index from the key.index of key to usexor_basePerforms XOR operation on the input data using the base and the key start and end positions.base to use, start/end key to usexor_addAdds the key start and end values to the input data using XOR addition.start/end key to useYou can combine these encryption methods in a custom configuration to suit your specific requirements.Encryption ConfigurationsIn addition to creating your own custom encryption configurations,ascii_chiperprovides several pre-configured encryption configurations that cater to different use cases and security levels:BASIC_SWAP_INTERLEAVE: A simple configuration that combines Swap and Interleave encryption methods for basic security.ROTATE_XORSHIFT: Combines the Rotate and XorShift methods for an intermediate level of security.XORBASE_ROTATE: Combines the XorBase and Rotate methods for enhanced security.XORADD_INTERLEAVE: Combines the XorAdd and Interleave methods for a higher level of security.FULL_ENCRYPTION: Uses all available encryption methods for maximum security.Remember to use the same encryption configuration for both encryption and decryption to ensure proper functionality.Personal ThoughtsI hope you find this module useful. This module is the exact Python implementation of the encryption method used by a well-known web anti-bot system. If you know what I'm talking about, you'll definitely find it useful.
Please feel free to contact me for any help or suggestions viaEmailorTwitter. I appreciate your feedback and contributions to the project.LicenseThis project is licensed under the MITLicense. See the LICENSE file for more details.My linksProject repositoryGitHubTwitterMediumEmail