Skip to main content

A command line tool to split a file into horcruxes, so that the original can be recreated with at least k horcruxes

Project description

horcruxes

Totally unorignal, but smaller and faster.

horcruxes is a python package to split a file into n encrypted horcruxes, such that any k can be used to recreate the original file.

                    /————> filth.mp4_1_of_5.hcx 
                   /—————> filth.mp4_2_of_5.hcx —————\ 
  filth.mp4   ————<——————> filth.mp4_3_of_5.hcx ——————>———> filth.mp4
                   \—————> filth.mp4_4_of_5.hcx —————/
                    \————> filth.mp4_5_of_5.hcx 

                              (n=5, k=3)

How's it do that?

A secret is created and made into several shares using Shamir's Secret Sharing. Then, the secret is used to encrypt the content of the input file using AES-256.

Each horcrux file contains a short header and zero or more blocks of encrypted data. This data is then arranged in a "(k, 1) repetition code of blocks striped over n files". As an example, for n=5, k=3, where the file has been divided into seven blocks, the following file structure is created:

File 1 File 2 File 3 File 4 File 5
a a a b b
b c c c d
d d e e e
f f f g g
g - - - -

Any three files together contain at least a single copy of every block without having to create 5 copies of each block.

Performance

This module shows considerably faster and smaller results than the one I stole the idea from.

Tested on a 1GB file, n=10, k=8:

File size

Mine Other Ratio
Size per horcrux 300MB 1GB 3.3
Size for k horcruxes 2.4GB 8GB 3.3
Size of n horcruxes 3 GB 10 GB 3.3

The size per horcrux per horcrux is given by original size * (n-k+1)/n. The closer k is to n, the larger the size reduction.

Slower IO (HDD)

Test Mine Other Ratio
split 23.37s 706.43s 30.22
bind 14.93s 50.17s 3.36

Fast IO (SSD)

Test Mine Other Ratio
split 52.29s 130.52s 2.49
bind 9.67s 11.73 1.213

This tool shows faster results in both cases, largely due to the fewer IO operations required, but also because AES is ridiculously optimized.

Other improvements

It's now true to the actual Harry Potter lore, as you can create horcruxes with k=1.

But why?

Getting it

The entire repo is just a pip package, but it's also on PyPI:

pip install horcruxes

Credits

It's an absolutely unoriginal idea.

https://github.com/jesseduffield/horcrux — same as mine, but slower

http://point-at-infinity.org/ssss/ — similar concept, not meant for files

https://github.com/kndyry/horcrux — not entirely the same, this one requires n = k

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

horcruxes-2.7.post2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

horcruxes-2.7.post2-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file horcruxes-2.7.post2.tar.gz.

File metadata

  • Download URL: horcruxes-2.7.post2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

File hashes

Hashes for horcruxes-2.7.post2.tar.gz
Algorithm Hash digest
SHA256 557610e4a4e59ed2b1cf056996a0c4987b27c096f3c245ccb3e0735b09a2076e
MD5 256e7c16cb843d82d3fef585fc7fd677
BLAKE2b-256 231e63ff1838505795bb5071f658525cd672735b4f8576746325e2ee5eb54ff7

See more details on using hashes here.

File details

Details for the file horcruxes-2.7.post2-py3-none-any.whl.

File metadata

  • Download URL: horcruxes-2.7.post2-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

File hashes

Hashes for horcruxes-2.7.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 694b89ba46a9f47f3a7be4b5ab60ca300959ca8fc605bd17a0461ff668ee0cb9
MD5 898d4dd17092a8739568ffda0925d61a
BLAKE2b-256 20003bb1bfa7446b1f1a0d43b4753cf5cd33ff190315088db98b1151089bc6ea

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