summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Sorensen <aedrax@gmail.com>2018-02-14 23:35:29 -0500
committerGitHub <noreply@github.com>2018-02-14 23:35:29 -0500
commit349353d1c712ed304bc9940500dfc989045121fb (patch)
treea32bfa0dd924f5d2d6fc282a34e8f6c10bad4b2a
parent2209d8c538e51daba96e25a287245aa12023b65d (diff)
downloadSorensenCompression-349353d1c712ed304bc9940500dfc989045121fb.tar.gz
SorensenCompression-349353d1c712ed304bc9940500dfc989045121fb.zip
Create GarbageProofOfConcept.py
-rw-r--r--GarbageProofOfConcept.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/GarbageProofOfConcept.py b/GarbageProofOfConcept.py
new file mode 100644
index 0000000..0c07873
--- /dev/null
+++ b/GarbageProofOfConcept.py
@@ -0,0 +1,44 @@
+import hashlib
+from itertools import combinations
+
+data = "abc"
+length = len(data)
+
+hexdigest = hashlib.sha256(data).hexdigest()
+print(hexdigest)
+
+lookupTable = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3,
+ 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2,
+ 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4,
+ 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2,
+ 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4,
+ 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5,
+ 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3,
+ 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3,
+ 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6,
+ 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4,
+ 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5,
+ 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8]
+
+sum1 = 0
+for i in xrange(length):
+ sum1 += lookupTable[bytearray(data)[i]]
+
+print("The length is: {0}").format(length)
+print("The ones count is: {0}").format(sum1)
+
+combinations = list(combinations(range(length * 8),sum1))
+numCombs = len(combinations)
+
+count = 1
+for comb in combinations:
+ print("Trying {0}/{1}").format(count, numCombs)
+ count += 1
+ a = [0] * length
+ for bit in comb:
+ a[bit/8] |= 1 << (bit % 8)
+ if hashlib.sha256(bytearray(a)).hexdigest() == hexdigest:
+ print("Found! {0}").format(a)
+ break
+else:
+ print("failed to find")