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

  • SEARCH
  • Home
  • 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 88499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:34:10+00:00 2026-05-10T22:34:10+00:00

First, context: I’m trying to create a command-line-based tool (Linux) that requires login. Accounts

  • 0

First, context: I’m trying to create a command-line-based tool (Linux) that requires login. Accounts on this tool have nothing to do with system-level accounts — none of this looks at /etc/passwd.

I am planning to store user accounts in a text file using the same format (roughly) as /etc/passwd.

Despite not using the system-level password files, using crypt seemed to be a good practice to use, as opposed to storing passwords in cleartext. (While crypt is certainly better than storing passwords in cleartext, I’m open to other ways of doing this.)

My crypt knowledge is based on this: https://docs.python.org/2/library/crypt.html

The documentation seems to ask for something that isn’t possible: ‘it is recommended to use the full crypted password as salt when checking for a password.’

Huh? If I’m creating the crypted password (as in, when creating a user record) how can I use the crypted password as a salt? It doesn’t exist yet. (I’m assuming that you must use the same salt for creating and checking a password.)

I’ve tried using the plaintext password as a salt. This does work, but has two problems; one easily overcome, and one serious:

1) The first two letters of the plaintext password are included in the crypted password. You can fix this by not writing the first two characters to the file:

user_record = '%s:%s:%s' % (user_name, crypted_pw[2:], user_type) 

2) By using the plaintext password as the salt, you would seem to be reducing the amount of entropy in the system. Possibly I’m misunderstanding the purpose of the salt.

The best practice I’ve been able to derive is to use the first two characters from the username as the salt. Would this be appropriate, or is there something I’ve missed that makes that a bad move?

My understanding of a salt is that it prevents pre-computing password hashes from a dictionary. I could use a standard salt for all passwords (such as my initials, ‘JS,’) but that seems to be less of a burden for an attacker than using two characters from each user’s username.

  • 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. 2026-05-10T22:34:11+00:00Added an answer on May 10, 2026 at 10:34 pm

    For the use of the crypt module:

    When GENERATING the crypted password, you provide the salt. It might as well be random to increase resistance to brute-forcing, as long as it meets the listed conditions. When CHECKING a password, you should provide the value from getpwname, in case you are on a system that supports larger salt sizes and didn’t generate it yourself.

    General comments:

    If this has nothing to do w/ actual system logins, there is nothing preventing you from using a stronger method than crypt. You could randomly generate N characters of per-user salt, to be combined with the user’s password in a SHA-1 hash.

    string_to_hash = user.stored_salt + entered_password successful_login = (sha1(string_to_hash) == user.stored_password_hash) 

    UPDATE: While this is far more secure against rainbow tables, the method above still has cryptographic weaknesses. Correct application of an HMAC algorithm can yet further increase your security, but is beyond my realm of expertise.

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

Sidebar

Ask A Question

Stats

  • Questions 88k
  • Answers 88k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If only 1500 of these can be served per 5… May 11, 2026 at 5:44 pm
  • Editorial Team
    Editorial Team added an answer Code example here (in C): http://www.mail-archive.com/sqlite-users@sqlite.org/msg15929.html May 11, 2026 at 5:44 pm
  • Editorial Team
    Editorial Team added an answer There are three common techniques for this. 1) DataTrigger: <DataTemplate… May 11, 2026 at 5:44 pm

Related Questions

First, context: I'm trying to create a command-line-based tool (Linux) that requires login. Accounts
From a couple of preliminary tests it seems that EnumWindows always returns windows in
Question: IE and Firefox / Safari seem to deal differently with BASE HREF and
I'm trying to implement some very simple line drawing animation for my iPhone app.
I have UserControl that holds Infragistics Graph control. On the TreeView sub node's right

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.