commit f5249ee68be154861d37c76082b45400a14c4a2d Author: Jack Halford Date: Sat Apr 15 19:38:47 2023 +0200 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..fdc807d --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# horQRux + +### Disclaimer + +This is only a proof of concept, don't use it to protect serious data. + +### Proof of concept + +By splitting a QR code into 7 fragments, we may physically split and distribute a secret into the real world. For example by printing the QR fragments onto transparent paper and handing them out to multiple people. + +![full](example/horcrux_full.svg) = ![1](example/horcrux_1.svg) + ![2](example/horcrux_2.svg) + ![3](example/horcrux_3.svg) + ![4](example/horcrux_4.svg) + ![5](example/horcrux_5.svg) + ![6](example/horcrux_6.svg) + ![7](example/horcrux_7.svg) diff --git a/example/generate.sh b/example/generate.sh new file mode 100755 index 0000000..4cb7bf3 --- /dev/null +++ b/example/generate.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +../horqrux.py "hello hackernews" diff --git a/example/horcrux_1.svg b/example/horcrux_1.svg new file mode 100644 index 0000000..335595c --- /dev/null +++ b/example/horcrux_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/horcrux_2.svg b/example/horcrux_2.svg new file mode 100644 index 0000000..0bc2c20 --- /dev/null +++ b/example/horcrux_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/horcrux_3.svg b/example/horcrux_3.svg new file mode 100644 index 0000000..d140b34 --- /dev/null +++ b/example/horcrux_3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/horcrux_4.svg b/example/horcrux_4.svg new file mode 100644 index 0000000..e948281 --- /dev/null +++ b/example/horcrux_4.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/horcrux_5.svg b/example/horcrux_5.svg new file mode 100644 index 0000000..169a043 --- /dev/null +++ b/example/horcrux_5.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/horcrux_6.svg b/example/horcrux_6.svg new file mode 100644 index 0000000..e6dfd30 --- /dev/null +++ b/example/horcrux_6.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/horcrux_7.svg b/example/horcrux_7.svg new file mode 100644 index 0000000..8a3345c --- /dev/null +++ b/example/horcrux_7.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/horcrux_full.svg b/example/horcrux_full.svg new file mode 100644 index 0000000..2c38a9e --- /dev/null +++ b/example/horcrux_full.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/horqrux.py b/horqrux.py new file mode 100755 index 0000000..337bff8 --- /dev/null +++ b/horqrux.py @@ -0,0 +1,32 @@ +#!/bin/env python + +import random +import sys +from copy import copy + +import qrcode +import qrcode.image.svg +from bs4 import BeautifulSoup +from more_itertools import chunked_even + +factory = qrcode.image.svg.SvgFragmentImage +qrcode = qrcode.make(sys.argv[1], image_factory=factory) +svg_string = qrcode.to_string(encoding='unicode') +with open("horcrux_full.svg", 'w') as f: + f.write(svg_string) +svg = BeautifulSoup(svg_string, 'xml') +svg_object = svg.find('svg:svg') + +rects = svg.find_all('svg:rect') +random.shuffle(rects) +horcruxes = chunked_even(rects, len(rects)//6) + +svg_object.clear() + +# write horcruxes to svg files +for idx, horcrux in enumerate(horcruxes): + horcrux_svg = copy(svg_object) + for rect in horcrux: + horcrux_svg.append(rect) + with open(f"horcrux_{idx + 1}.svg", 'w') as f: + f.write(str(horcrux_svg)) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..24a4982 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +beautifulsoup4 +more-itertools +qrcode