diff --git a/arty_new.png b/arty_new.png index dec05b3..ae787a7 100644 Binary files a/arty_new.png and b/arty_new.png differ diff --git a/encode_image.rb b/encode_image.rb index 9e6d7d1..bb10334 100644 --- a/encode_image.rb +++ b/encode_image.rb @@ -30,17 +30,6 @@ class EncodeImage msg_bits = pixel.encodeBits(msg_bits) end -# for x in 0..s[:width]-1 -# for y in 0..s[:height]-1 - -# loc = {"x": x, "y": y} -# if @@table.include? loc then -# pixel = @@utils.getImage.getPixel(x, y) -# msg_bits = pixel.encodeBits(msg_bits) -# end -# end -# end - @@utils.getImage.saveImage end diff --git a/image_utils.rb b/image_utils.rb index 8f7ee56..2b81a42 100644 --- a/image_utils.rb +++ b/image_utils.rb @@ -14,7 +14,7 @@ class ImageUtils @@password = pass @@message = msg - if msg.length > 400 then + if msg.length > 1024 then puts "Maximum length exceeded. Exiting." exit end @@ -34,9 +34,32 @@ class ImageUtils h = Digest::SHA512.hexdigest(@@password) s = @@pixelImg.getSalt - merge_to_i = h + s + @@hash = Digest::SHA512.hexdigest(self.interlaceHash(h, s)) + end - @@hash = Digest::SHA512.hexdigest(h+s) + def interlaceHash(h1, h2) + puts h1 + puts h2 + + h1 = self.getBits(h1) + h2 = self.getBits(h2) + + interlaced = 0 + + while h1.to_i > 0 and h2.to_i > 0 do + interlaced = (interlaced << 1) | (h1 & 1) + h1 = h1 >> 1 + interlaced = (interlaced << 1) | (h2 & 1) + h2 = h2 >> 1 + +# puts interlaced +# puts h1 +# puts h2 + end + + puts interlaced.to_s.inspect + + return interlaced.to_s end def generateLookupTable @@ -78,4 +101,16 @@ class ImageUtils return tbl end + + def getBits(o) + msg_bytes = o.unpack("c*") + + msg_bits = 0 + + for b in msg_bytes + msg_bits = (msg_bits << 8) | b + end + + return msg_bits + end end \ No newline at end of file diff --git a/runner.rb b/runner.rb index 018ccfb..4ef178f 100644 --- a/runner.rb +++ b/runner.rb @@ -3,12 +3,20 @@ require "rmagick" require "./image_utils.rb" require "./encode_image.rb" -img = Magick::ImageList.new "./images/original/arty_2.jpg" +img = Magick::ImageList.new "./images/original/arty.png" #srand(12345) pass = "my_password" message = "This is the message that I would like to save please " + + "and thank you also I love you? AND apostrophe's, and " + + "also some commas somewhere hiding around here, It's " + + "gonna be pushing it a bit here... 1234567 let's huck " + + "some more stuff in here to bump it to 255. Wow. We " + + "are going even further. further than anyone believed " + + "`~!@\#\{$%^&*()-_=+\][}{';:'}]} Wooow. 123456789!1234" + + "56789! so put 15 more??????400! TIMES TWO!! " + + "This is the message that I would like to save please " + "and thank you also I love you? AND apostrophe's, and " + "also some commas somewhere hiding around here, It's " + "gonna be pushing it a bit here... 1234567 let's huck " +