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 7031487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:48:34+00:00 2026-05-28T00:48:34+00:00

Hi I have a simple form that allows a user to input a name,

  • 0

Hi I have a simple form that allows a user to input a name, their gender and a password. I use Digest::MD5.hexdigest to encrypt the input. Once I have the encrypted input eg, d1c261ede46c1c66b7e873564291ebdc, I want to be able to append this to a file I have already created. However every thing I have tried just isn’t working. Can anyone please help and thank you in advance. Here is what I have:

input = STDIN.read( ENV["CONTENT_LENGHT"] )
puts "Content-type: text/html \n\n"

require 'digest/md5'
digest = Digest::MD5.hexdigest(input)

f = File.open("register.txt", "a")
    f.write(digest)
f.close

I have also tried this with no luck:

File.open("register.txt", "a") do |f|
    f.puts(digest)
end
  • 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-05-28T00:48:35+00:00Added an answer on May 28, 2026 at 12:48 am

    If the code is verbatim then I think you have a typo in the first line: did you mean CONTENT_LENGHT or is it a typo? ENV[] will return a string if the variable is set, which will upset STDIN#read. I get TypeError: can't convert String into Integer. Assuming the typo, then ENV[] returns nil, which tells STDIN#read to read until EOF, which from the console means, I think, Control-Z. That might be causing a problem.

    I suggest you investigate by modifying your script thus:

    read_length = ENV["CONTENT_LENGTH"].to_i # assumed typo fixed, convert to integer
    puts "read length = #{read_length}"
    input = STDIN.read( read_length )
    puts "input = #{input}"
    puts "Content-type: text/html \n\n" # this seems to serve no purpose
    
    require 'digest/md5'
    digest = Digest::MD5.hexdigest(input)
    puts "digest = #{digest}"
    
    # prefer this version: it's more idiomatically "Rubyish"
    File.open("register.txt", "a") do |f|
      puts "file opened"
      f.puts(digest)
    end
    
    file_content = File.read("register.txt")
    puts "done, file content = #{file_content}"
    

    This works on my machine, with the following output (when CONTENT_LENGTH set to 12):

    read length = 12
    abcdefghijkl
    input = abcdefghijkl
    Content-type: text/html
    
    digest = 9fc9d606912030dca86582ed62595cf7
    file opened
    done, file content = 6cfbc6ae37c91b4faf7310fbc2b7d5e8
    e271dc47fa80ddc9e6590042ad9ed2b7
    b0fb8772912c4ac0f13525409c2b224e
    9fc9d606912030dca86582ed62595cf7
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple HTML Form that allows the user to enter some text
I have a form that allows a user to add an unlimited number of
We have a form that allows a user to filter a list with by
I have a query builder form that allows a user to enter values into
I would like to create a form that allows the user to input any
I am attempting to display a form that allows a user to input a
I have a text field that accepts user input in the form of delimeted
I have a form that allows the user to perform a myriad of searches.
I have a simple form that looks like so <% remote_form_for post, :url =>
I have a simple form that searches through the 2000+ issues of a 3rd

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.