Compare commits
1 commit
main
...
efficient_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a71a1b6356 |
4 changed files with 10 additions and 52 deletions
BIN
arty_new.png
BIN
arty_new.png
Binary file not shown.
|
Before Width: | Height: | Size: 1 MiB After Width: | Height: | Size: 2.4 MiB |
|
|
@ -6,13 +6,14 @@ class EncodeImage
|
||||||
|
|
||||||
@@utils = nil
|
@@utils = nil
|
||||||
|
|
||||||
|
|
||||||
def initialize(p, m, i)
|
def initialize(p, m, i)
|
||||||
@@password = p
|
@@password = p
|
||||||
@@message = m
|
@@message = m
|
||||||
|
|
||||||
@@utils = ImageUtils.new(@@password, @@message, i)
|
@@utils = ImageUtils.new(@@password, @@message, i)
|
||||||
|
|
||||||
|
@@original_name = n
|
||||||
|
|
||||||
@@table = @@utils.generateLookupTable
|
@@table = @@utils.generateLookupTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -33,9 +34,7 @@ class EncodeImage
|
||||||
@@utils.getImage.saveImage
|
@@utils.getImage.saveImage
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Need to properly sever this at some point...
|
# Need to properly sever this at some point...
|
||||||
|
|
||||||
def decode
|
def decode
|
||||||
puts "Hacked in decode..."
|
puts "Hacked in decode..."
|
||||||
s = @@utils.getImage.getSize
|
s = @@utils.getImage.getSize
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class ImageUtils
|
||||||
@@password = pass
|
@@password = pass
|
||||||
@@message = msg
|
@@message = msg
|
||||||
|
|
||||||
if msg.length > 1024 then
|
if msg.length > 400 then
|
||||||
puts "Maximum length exceeded. Exiting."
|
puts "Maximum length exceeded. Exiting."
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
@ -34,32 +34,9 @@ class ImageUtils
|
||||||
h = Digest::SHA512.hexdigest(@@password)
|
h = Digest::SHA512.hexdigest(@@password)
|
||||||
s = @@pixelImg.getSalt
|
s = @@pixelImg.getSalt
|
||||||
|
|
||||||
@@hash = Digest::SHA512.hexdigest(self.interlaceHash(h, s))
|
merge_to_i = h + s
|
||||||
end
|
|
||||||
|
|
||||||
def interlaceHash(h1, h2)
|
@@hash = Digest::SHA512.hexdigest(h+s)
|
||||||
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
|
end
|
||||||
|
|
||||||
def generateLookupTable
|
def generateLookupTable
|
||||||
|
|
@ -101,16 +78,4 @@ class ImageUtils
|
||||||
|
|
||||||
return tbl
|
return tbl
|
||||||
end
|
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
|
end
|
||||||
14
runner.rb
14
runner.rb
|
|
@ -3,20 +3,14 @@ require "rmagick"
|
||||||
require "./image_utils.rb"
|
require "./image_utils.rb"
|
||||||
require "./encode_image.rb"
|
require "./encode_image.rb"
|
||||||
|
|
||||||
img = Magick::ImageList.new "./images/original/arty.png"
|
img_name = "arty"
|
||||||
|
|
||||||
|
img = Magick::ImageList.new "./images/original/" + img_name + ".jpg"
|
||||||
|
|
||||||
#srand(12345)
|
#srand(12345)
|
||||||
|
|
||||||
pass = "my_password"
|
pass = "my_password"
|
||||||
message = "This is the message that I would like to save please " +
|
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 " +
|
"and thank you also I love you? AND apostrophe's, and " +
|
||||||
"also some commas somewhere hiding around here, It's " +
|
"also some commas somewhere hiding around here, It's " +
|
||||||
"gonna be pushing it a bit here... 1234567 let's huck " +
|
"gonna be pushing it a bit here... 1234567 let's huck " +
|
||||||
|
|
@ -34,7 +28,7 @@ puts "Initializing EncodeImage..."
|
||||||
|
|
||||||
start = Time.new.to_f
|
start = Time.new.to_f
|
||||||
|
|
||||||
em = EncodeImage.new(pass, message, img)
|
em = EncodeImage.new(pass, message, img, img_name)
|
||||||
|
|
||||||
puts em.encode
|
puts em.encode
|
||||||
puts "Took " + (Time.new.to_f - start).to_s + " seconds to encode... 🐱"
|
puts "Took " + (Time.new.to_f - start).to_s + " seconds to encode... 🐱"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue