Skip to main content

Python encryption bluepy.

Project description

Python Bluepoint Encryption

Full symetric block cypher encryption algorythm

Installation:

pip install bluepyenc

Source:

https://github.com/pglen/bluepyinc

Quick example:

    import bluepyenc
    buff = "Hello, this is a test string.";
    passw = "1234"                          # This is a test
    enc = bluepyenc.encrypt(buff, passw)
    dec = bluepyenc.decrypt(enc, passw)
    assert buff == dec

The power of the encryption comes from the following primitives: (implemented as 'C' macros)

    HECTOR(op)              use op with vector highs
    PASSLOOP(op)            use op with pass as vector
    FWLOOP(op)              forward loop traverse
    FWLOOP2(op)             forward loop variation
    BWLOOP(op)              backward loop
    BWLOOP2(op)             backward loop variation
    MIXIT(op)               mix op on first part with second part
    MIXITR(op)              mix op on first part with second part reverse
    MIXIT2(op)              mix op on first part with second part variation
    MIXIT2R(op)             mix op on first part with second part variation in reverse
    MIXIT4(op)              mix quarter length

These are then added into encrypt operations. Please note that the parameter op is a mathematical / logical operation. (plus, minus, xor ...) The decryption is done in reverse order and reverse operator. (ex: '+' -> '-')

The power comes from the arbitrary order of operators and the arbitrary injection of reversible mathematical / logical operators.

Bluepy has the following operator stack:

Encryption:

PASSLOOP(+)
MIXIT2(+)   MIXIT2R(+)
HECTOR(+)   FWLOOP(+)
MIXIT2(+)   MIXIT2R(+)
PASSLOOP(+) FWLOOP(+)
HECTOR(+)   FWLOOP(+)
MIXITR(+)
BWLOOP(+)   HECTOR(+)

Decryption:

HECTOR(-)   BWLOOP2(-)
MIXITR(-)
FWLOOP2(-)  HECTOR(-)
FWLOOP2(-)  PASSLOOP(-)
MIXIT2R(-)  MIXIT2(-)
FWLOOP2(-)  HECTOR(-)
MIXIT2R(-)  MIXIT2(-)
PASSLOOP(-)

The resulting bit propagation is such high quality, that a single bit change in the original text will change every byte in the resulting block. (see bit description study in the code's directory)

One may create a custom encryption by altering the operator stack in the 'C' source.

This beats current industrial strength encryptions, and perhaps qualifies for the quantum challenge.

Decryption is done by applying the ops in reverse, both by order and meaning. This is very apparent in the functions ENCRYPT() and DECRYPT(). (see source)

Encryption quality test:

The cyphertext is tested for randomness with the 'dieharder' suite. All tests are passed. Below, is an extract of the utility's printout.

   diehard_birthdays|   0|       100|     100|0.07973936|  PASSED
      diehard_operm5|   0|   1000000|     100|0.22646819|  PASSED
  diehard_rank_32x32|   0|     40000|     100|0.62699248|  PASSED
    diehard_rank_6x8|   0|    100000|     100|0.66828243|  PASSED
   diehard_bitstream|   0|   2097152|     100|0.55151892|  PASSED
        diehard_opso|   0|   2097152|     100|0.04670626|  PASSED
        diehard_oqso|   0|   2097152|     100|0.06864521|  PASSED
         diehard_dna|   0|   2097152|     100|0.72141254|  PASSED
diehard_count_1s_str|   0|    256000|     100|0.68376408|  PASSED

The bluefile encryption / decryption utility

This utility can be used as a quick command line encryption / decryption utility. One of encrypt / decrypt must be specified.

    Usage: blueencfile.py [-e] [-d] [options] fromfile tofile
    Specify -e for encrypt -d decrypt
    Options:    -p pass   - pass to use
                -f        - force overwrite
                -v        - Verbose
                -V        - Print version
                -q        - Quiet
                -h        - Help

TODO;

Started the virtual machine operation, where the encryption is run through a virtual machine stack, following a pre-made recipe or getting hints from the password.

History:

Release                 Thu 13.Oct.2022
Pip install             Sat 03.Jan.2026
Published on GH         Sun 04.Jan.2026

Warning!

No metadata is stored. It is left up to the caller to maintain data integrity beyond the cyphertext operations.

The encryption / decryption has to run with the same vector, same pass same block length. Make sure you know what you are doing, as it is all too easy to encrypt something into oblivion.

Colophon:

This project is a descendent of the bluepoint encryption algorithm, crafted in 'C'.

EOF

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

bluepyenc-1.2.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

bluepyenc-1.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (32.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file bluepyenc-1.2.0.tar.gz.

File metadata

  • Download URL: bluepyenc-1.2.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for bluepyenc-1.2.0.tar.gz
Algorithm Hash digest
SHA256 8bd25c4779f0c14a9a4737ccec878472a2a864252e96ac55651cacb715740497
MD5 32cc138b7a3f274534073e82c0c3745d
BLAKE2b-256 b065b76415e83d2f6e51565f7e6c21fd93f74c3e19a25eb5167597d604d61ef4

See more details on using hashes here.

File details

Details for the file bluepyenc-1.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for bluepyenc-1.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 392cfc2d16af0a7c8127ea1b656826cecf3232a39368cff1aba2a96cb849f412
MD5 1b87a46f975a0eb7d8474716a16ff9ad
BLAKE2b-256 0fdb3b6a962a41542f1a88ef57d64202e77e85a7e8ee79059b291e2f6f831177

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