Skip to main content

Simple XOR Encryptor

Project description

Encrypting library for python

This library provides a socket encryption method based on XOR and Diffie-Hellman algorithm

Examples

Using the Encrypt method

import encrypting

pair = encrypting.generate_pair() # Used for 2 sides

alice = encrypting.Encrypt(pair)
bob = encrypting.Encrypt(pair)

alice.init(bob.mixture) # Initializing encryption
bob.init(alice.mixture)

e = alice.crypt(b'Your bytes')
d = bob.crypt(e) # The function for encryption and decryption is the same

print(d) # Printing b'Your bytes'

Using the EncryptedSocket

Server (multithread):

import encrypting

def handler(sock, addr): # sock: EncryptedSocket class
	print('Connected:', addr)
	data = sock.recv(1024) # Receiving an encrypted message and decrypting it
	sock.send(data) # Encrypting a message and sending it
	return


bind_addr = ('127.0.0.1', 1234)

sock = encrypting.EncryptedSocket()

sock.serve(bind_addr, handler) # Starting the server (goes into an infinite loop waiting for connections)

Client:

import encrypting

connect_addr = ('127.0.0.1', 1234)

sock = encrypting.EncryptedSocket()

server = sock.connect(connect_addr) # Connect to the server and create a secure connection

while True:
	message = input('Message > ').encode()
	server.send(message)
	data = server.recv(1024).decode()
	print('Server:', data)

EncryptedClient object

  • Creating an object: EncryptedClient(socket, Encrypt)

Methods:

  • EncryptedClient(socket, Encrypt).send(bytes) - sending bytes to the server
  • EncryptedClient(socket, Encrypt).recv(n_bytes) - recieving bytes from the server
  • EncryptedClient(socket, Encrypt).close() - close the connection

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

encrypting-0.3-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file encrypting-0.3-py3-none-any.whl.

File metadata

  • Download URL: encrypting-0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for encrypting-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 faee922ffa1effeca3bb08984221ca07274f4223d397f5c7dcdd30be76f5fb6a
MD5 3d96a63bf3aeeaa2b03aa05aa591467c
BLAKE2b-256 1694efc4b96954b7c38412400d4d64e958e8dc7210aa3168e8c98599d95ae802

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page