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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:41:25+00:00 2026-06-17T04:41:25+00:00

I’m using Python’s crypt package to persist encrypted passwords in a MySQL databse for

  • 0

I’m using Python’s crypt package to persist encrypted passwords in a MySQL databse for a Django website. I’m not sure if this is a bug, but here’s the code I’m using:

To encrypt/persist the password:

user.password = crypt(request.POST['password'], netid)
user.save()

To check for a correct password on login:

if crypt(password, email) == user.password:
# Grant acccess to the user's profile, etc.

The problem is the following. If I encrypt a password with variable netid = test@example.com and request.POST['password'] = 'ABC123abc', it works fine. However, when I try to login, if I use the password 'ABC123abc[trailing_chars]', where the trailing_chars can be any valid string, I am still able to log in. Why is this? It poses to be a large security hole as is.

  • 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-17T04:41:26+00:00Added an answer on June 17, 2026 at 4:41 am

    First of all, you should not be using an email address as a salt (the second argument) for crypt. This is not secure. You MUST pick a good random salt.

    For traditional crypt, the salt is a two-character string chosen from the set [a–zA–Z0–9./]. This version of crypt accepts only 8 input characters and discards all following characters from the input after the 8th. That is what you’re seeing here.

    Modern crypt implementations also support other algorithms that are cryptographically much stronger than traditional crypt but they are not available on all platforms. The new algorithms also don’t limit the input to 8 characters.

    To use one of these better algorithms (if you are using a platform that supports them), you need to supply a salt that is in a special format. This is how the function recognizes that you would like to use an alternate algorithm.

    For the extra algorithms supported by glibc (and therefore available on GNU/Linux), consult the “Glibc Notes” section of the crypt manpage.

    By the way, when checking the password, you don’t need to manually extract the salt. The encrypted password already starts with the salt, so just pass user.password (not email) as the second argument to crypt. This works whether you are using the old algorithm or one of the new ones. The choice of algorithm and generation of a salt in the correct format need only be done when encrypting the password, not when verifying it.

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

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

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.