Problems with Zlib::Inflate.inflate

C

Chris Malek

I am running on windows xp and trying to inflate a string and decode
it. I am getting a

When I try to execute this script I get the following error:

deflateBase64.rb:11: uninitialized constant Zlib (NameError)


Ruby Version: 1.8.2


##########################################
require 'base64'
f = File.open("c:/temp/string.txt","r")
fout = File.open("c:/temp/decodedString","w")
fout.puts(Zlib::VERSION )
while (ln = f.gets)
inflatedString = Zlib::Inflate.inflate ln
decodeString = Base64.decode64(inflatedString)
fout.puts(decodeString)
f.close
fout.puts("closing")
fout.close


end

##########################################




Anyone have any idea?

Thanks in advance.
 
C

Chris Malek

I tried to require zlib and I get the following error. I know it has
to be simple.



c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/Zlib.so: 127: The specified
procedure could not be found. - Init_Zlib (LoadError)
c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/Zlib.so from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'

That errror was generated from this script

################################################################

require 'base64'
require 'Zlib'

f = File.open("c:/temp/string.txt","r")
fout = File.open("c:/temp/decodedString","w")

fout.puts(Zlib::VERSION )

while (ln = f.gets)

inflatedString = Zlib::Inflate.inflate ln
begin
decodeString = Base64.decode64(inflatedString)
fout.puts(decodeString)
rescue StandardError => err
fout.puts("an exception occured #{err}\n")
print "an exception occured #{err}\n"
rescue SyntaxError
fout.puts("o shit syntax")
ensure
f.close
fout.puts("closing")
fout.close

end


end




##################################################################
 
C

Chris Malek

Forget my last reply. I had a case issue in the require. It turns out
zlib has to be lower case. That was my blond moment of the day.


My revised script is now throwing a different error and a google search
turns up nothing useful.

the error when running this script is:

"invalid distance too far back"




#########################################################
require 'base64'
require 'zlib'

begin
f = File.open("c:/temp/string.txt","r")
fout = File.open("c:/temp/decodedString","w")

while (ln = f.gets)
begin
decodeString = Base64.decode64(ln)
fout.puts("Here comes the decoded string \n")
fout.puts(decodeString)
inflatedString = Zlib::Inflate.inflate decodeString

fout.puts("here comes the inflated string \n\n")
fout.puts(inflatedString)
rescue StandardError => err
fout.puts("an exception occured \n #{err}\n")
print "an exception occured #{err}\n"
end #block under while loops
end #while loop

ensure
f.close
fout.puts("closing program from ensure")
fout.close


end #top begin section


#########################################################


The string in the file I am operating on is:

eJztmF1vmzAUhv9KlJteZdgQCEjElWNcghSc1JiqubKiLpoqZd1Uomn79zMfTY1Jq1VJ14ty5/O+PseHk0dWILz8/X03+LV9LO5/PEwv4BdwcYlClkvBMcsIT1ZC3ixzMqdcZmtGUHh1v919FX9+botmH5M3ZM5lhMXgbrcpiumQD1FI09UiiQZ7tXE6JHPMh5YSb4Vc8lh2DFWo9AjmlPLjnqqPJZs9uSxPZ7TyM3qtgo781PWxswinWFB5tcBx11zxhFXH0cYrl6VXG7NciCXrptkskpxe5zQThtmoMhJGQZVVLuUqny2SbG64ljFd1UBGcIr1KteS8wi3McU0nMp8R5lAiJiTBbneGMypfz0iyWaqJqNuZoVnxJaJbJhGUCM0I7E28eQ/J8QbtjV4XZMqIMp9RwrPq51EJnKy2+RZv9BoXicfNQbO72CtB/IA4BACAIAjcIrUbRsEPABtWGsXKf1TZ/KI95VI1f00wMETzsOEgNiqXVrDQKUQB91ZMmGCSidVVRV9o4ItW7O4JwBOqzNafFZjnRVtimE7EqW1c0RFWyHhiIli146vwRtKsiLe+txCLK4tDSBY1aVU0PTGrr3I6q46sqtCKTXwTKORmaCXE5S1PRSK7P0KIDyi1q347w2HE9Fx5HGMLxGDi+/54Ig6MIO14wOQPCYDyy7R7hz8wv9GznA/idlFdnz2/P76n82q7vfsj96/f89vyezq8T2O/6F/jF+xf0/Pb8nsav+gGgM/Em//8VTt2/53iFO53f9av81of4I9vrST4zydbhs4T1ykeyv+QRmHM=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top