Skip to main content

little Python library for encrypt and decrypt using XOR operation.

Project description

XOR Encryption

Total alerts Language grade: Python

XOR Encryption is a little Python library for encrypt and decrypt string with key. This library is for those of you who are learning encryption using the XOR method.

How it Works

The library uses a simple encryption algorithm that converts plain text and keys to binary form and then XORs them both to generate cipher text. Here's the mathematical notation:

XOR encryption notation

Because performing XOR operations with the same value twice in a row yields the original value, the following is the mathematical notation for decryption:

XOR decryption notation

Note:

  • P = Plain text
  • K = Key
  • C = Cipher text

How to Use

Example code:

from xorencryption import XOREncryption

plain = "this is your plain text"
key = "boom"
enc = XOREncryption()

enc.set_plaintext(plaintext=plain)
enc.set_key(key=key)

print(enc.encrypt())  # return cipher text
print(enc.decrypt())  # return decrypted text

Project details


Download files

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

Source Distribution

xorencryption-0.1.6.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file xorencryption-0.1.6.tar.gz.

File metadata

  • Download URL: xorencryption-0.1.6.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for xorencryption-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b53b21b83810ef8da8836f21f76d8231f03cf39b99c8337294c7887f15daaaaf
MD5 7861dbbf8a6674925ce4a987d0f15446
BLAKE2b-256 18d5b777595cc028c5c1d0abb40b521f4c62ebb2004ae8004a0e89a8968e71e7

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