Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9270449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:22:23+00:00 2026-06-18T15:22:23+00:00

My ruby script doesn’t seem to wait for my input. I’m trying to follow

  • 0

My ruby script doesn’t seem to wait for my input. I’m trying to follow a script that encrypts your file from the first chapter of the book: wicked cool ruby, but it doesn’t wait for my input after I run the file in command prompt.

Code snippet that is causing trouble:

require 'crypt/blowfish'

unless ARGV[0]
   puts "Usage: ruby encrypt.rb <filename.ext>"
   puts "Example: ruby encrypt.rb secret.stuff"
   exit
end

#take in the file name to encrypt as an argument
filename = ARGV[0].chomp
puts filename

c = "Encrypted_#{filename}"

if File.exists?(c)
   puts "File already exists."
   exit
end

print 'Enter your encryption key (1-56 bytes): '
kee = gets.chomp

begin
   blowfish = Crypt::Blowfish.new(kee)
   blowfish.encrypt_file(filename.to_str, c)
   puts 'Encryption SUCCESS!'
rescue Exception => e
   puts "An error occurred during encryption: \n #{e}"
end

What I see in cmd after I try to run the file:

C:\Users\me\>ruby new4.rb fileToEnrypt.txt
Enter your encryption key (1-56 bytes): An error occurred during encryption:
 can't convert String into Integer
C:\Users\me\>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:22:24+00:00Added an answer on June 18, 2026 at 3:22 pm

    You have two problems here:

    Concerning the fact that you don’t get the user prompt, replace your code with:

    kee = $stdin.gets.chomp
    

    Concerning the error message, it’s because:

    The key is anywhere between 64 and 448 bits (8 and 56 bytes), and
    should be passed as a packed string

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so i have ruby script that simply writes to a test.txt file with hello
I have a script that runs via a pipe and it doesn't seem to
I've written a Ruby script that is reading a file ( File.read() ) that
I am trying to write a small ruby script that will have two methods
I am trying to run a ruby script from my computer and I would
I'm trying to create a haml template that uses some data from my ruby
So I'm trying to run a executable from my ruby script, and pass in
I'm trying to send a POST request from an external Ruby script to a
I'm trying to run a Ruby script using rbenv with cron. I know that
I am trying to run a ruby script that uses inside a function that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.