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.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: encrypting-0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a23c66b02e18edd09ab6ac7acb91fb59594d1c077ed3474e76f625b9620021
MD5 70367c694a4b7acfb85d88e04c404fa4
BLAKE2b-256 37fd2efd46b79e2efde8ef0e94150d6af7bd6f6fe9af8b4715ac52e734f7c5f9

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