Skip to main content

Bit rotational encryption with steganography

Project description

Bitmasher - private key crypto algorithm based on bit buffer rotation and steganography

Algorithm.

Bitmasher is based on three encryption ideas combined in three passes of encryption.

  • XOR encryption of the data with rotational key
  • Mixing XOR encrypted block of data with a random data
  • Bit-rotation ROR/ROL (ROR/ROL for decryption), based on two random keys: one defining the depth of the rotation, other - directionality of the rotation.

So, in order to break encrypted block of data, you actually need to figure out two keys, and second stage mixing preventing statistical analysis. If you are interested to learn more about algorithm itself, please take a look at this slides. Buffer bit-rotating cryptography with steganography

"Hello World" of the Bitmasher

>>> from Bitmasher import *
>>> n = init()
>>> d = encrypt(n, "This is a BIG secret")
>>> print(decrypt(n, *d))
b'This is a BIG secret'
>>>
  • First, we have to import Bitmasher functions. Python 3.6 or newer is required.
  • Next, we initializing namespace for a crypto operations.
  • We are encrypting. Note, first parameter to a encrypt function is a reference to a namespace. You can pass any Python values, supported by msgpack serializing library.
  • Next, we decrypting. Please note, you have to pass namespace as first parameter.

This is all very simple

Where is my keys !!!!

Bitmasher does not trust you with keys generation. It maintain a "codebook" internally by generating keys on demand. First 1024 keys are generating while calling init(). Each block of data encrypting with uniq key. Key consisting of two parts:

  • Private key. serves as modulo for the XOR operation during the first pass and number of rotation at third pass.
  • Masher. Dataset defining directionality of the rotations at third pass.

Function encrypt returning the list of the tuples, where first element of the tuple is key ID and second element is encrypted data. In order to decrypt, you are expecting to load a "used pages" from codebook, that you received by secure means inside Bitmasher namespace.

How to export pages from a codebook which were used during encryption ?

>>> from Bitmasher import *
>>> n = init()
>>> d = encrypt(n, "This is a BIG secret")
>>> book = cryptobook_save(n)
>>> len(book)
21085
>>> book[:32]
b'\x82\xda\x00$1ba990f9-6b43-4a9d-9bc1-a820'

Yep, it is a msgpack data. And it is contains all your keys.

How to load pages from a codebook to use for decryption

>>> from Bitmasher import *
>>> n = init()
>>> d = encrypt(n, "This is a BIG secret")
.... saving and transferring cryptobook image
>>> n = cryptobook_load(n, book)
>>> print(decrypt(n, *d))
b'This is a BIG secret'

Fun stuff

Let's say, you have to transmit your secret message, encrypted with Bitmasher to your secret correspondent over a radio waves. LEGAL NOTE: this type of the operations is expressly prohibited by FCC rules and I am not responsible for the troubles you will get yourself into, if you will actually try this. So, do not do this for real. Dust off your straight key or paddle and get your telegram formatted.

>>> d = encrypt(n, "This is a BIG secret")
>>> d
[('cd34242a-c174-4769-b945-23f805d684cf', b'\x16\xb.....

After you get your encryption done ...

>>> tlg = telegram(d[0][1])
>>> print(tlg)
022 186 243 218 120 121 196 018
089 191 101 201 184 042 085 108
100 047 091 015 226 152 003 093
111 121 108 086 182 134 061 035
225 037 182 083 247 230 122 123
044 072 100 097 135 029 090 080
238 024 225 141 016 247 075 009
...

Breath deep and use your HAM radio skills for a something good.

73

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

Bitmasher-0.0.4.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

Bitmasher-0.0.4-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file Bitmasher-0.0.4.tar.gz.

File metadata

  • Download URL: Bitmasher-0.0.4.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.4

File hashes

Hashes for Bitmasher-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2af896345753dc3ff61b227456a64a6c4e87125e6e3e05b2dd117f0413f49b1d
MD5 ddfb6a6de42300de1c7652b7f2228152
BLAKE2b-256 2e2b95a116e66410cb618151ba8718cf99450e6192605c8f257749355fe0dfb7

See more details on using hashes here.

File details

Details for the file Bitmasher-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: Bitmasher-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.4

File hashes

Hashes for Bitmasher-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 09ac9cf6aaa47c4c83b25a9493b3fa3253d76d9acc5e834242508a3b6fd28f03
MD5 ef306e968499bd133a59961012d67a57
BLAKE2b-256 25f2ff218f96d5152ea7e6a75086660272b30bf55988903ccd5d01464df82831

See more details on using hashes here.

Supported by

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