huffman coding (WIP )

This commit is contained in:
ts
2018-10-09 12:42:04 +01:00
parent d73906d29c
commit 033b8b3a0d
2 changed files with 5 additions and 5 deletions

View File

@@ -13,12 +13,12 @@ class HuffmanEncoder < StringEncoder
Dir.mkdir '../tmp/' unless Dir.exists? '../tmp/'
end
def encode(str)
def encode_all
tree_path = "../tmp/tree_#{index}"
result = Huffman.encode_text(str, tree_picture: true, tree_path: tree_path)
result = Huffman.encode_text(strings_to_encode[0], tree_picture: true, tree_path: tree_path)
self.index += 1
# Return an array with the compressed string, and the tree png encoded in base64
[result.first, Base64.strict_encode64(File.binread("#{tree_path}.png"))]
self.outputs << result.first
self.outputs << Base64.strict_encode64(File.binread("#{tree_path}.png"))
end
end

View File

@@ -21,7 +21,7 @@
<datastore access="0">huffman_challenge</datastore>
</input>
<input into="images_to_leak">
<datastore access="0">huffman_challenge</datastore>
<datastore access="1">huffman_challenge</datastore>
</input>
</vulnerability>