A much better commit of the raw rmagick access. Huge time improvement for calculating the salt.

This commit is contained in:
monqui 2026-07-20 19:16:30 -04:00
parent 0b26d83313
commit e10bedee0f
4 changed files with 51 additions and 93 deletions

View file

@ -7,11 +7,11 @@ class EncodeImage
@@utils = nil
def initialize(p, m, i)
def initialize(p, m, uri)
@@password = p
@@message = m
@@utils = ImageUtils.new(@@password, @@message, i)
@@utils = ImageUtils.new(@@password, @@message, uri)
@@table = @@utils.generateLookupTable
end
@ -32,46 +32,4 @@ class EncodeImage
@@utils.getImage.saveImage
end
# Need to properly sever this at some point...
def decode
puts "Hacked in decode..."
s = @@utils.getImage.getSize
msg_bits = 0
@@table.reverse.each do |loc|
pixel = @@utils.getImage.getPixel(loc[:x], loc[:y])
msg_bits = (msg_bits << 6) | pixel.decodeBits
end
#this trash needs to move somewhere...
puts "Try to convert the message..."
len = msg_bits & 0xffff
msg_bits = msg_bits >> 16
# check the padding bits....
if (msg_bits & 255) != 0 then
puts "Padding failed scrutiny! "
puts msg_bits.to_s(2)
return false
end
msg_bits = msg_bits >> 8
puts "Padding passed scrutiny..."
msg_chars = []
while msg_bits > 0 do
byte = msg_bits & 0xff
msg_chars.push(byte.chr)
msg_bits = msg_bits >> 8
end
msg = msg_chars.reverse.join
return msg
end
end