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

Uploaded Python 3

File details

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

File metadata

  • Download URL: encrypting-0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 00ecde0db788067b0f43c4efb76d2509a983eb218aafa99513b20b768cf7b225
MD5 d5dc6e8055fda3facea2fad54173d936
BLAKE2b-256 98706776f4ef35464f03e246c4a2ebfe99827adb356020c78d703c73d91faa27

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