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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:35:02+00:00 2026-06-13T09:35:02+00:00

I have a Django application which resets unix user passwords running in an Ubuntu

  • 0

I have a Django application which resets unix user passwords running in an Ubuntu machine, but my development environment is OS X and I’ve come across this annoying situation:

OS X:

>>> import crypt
>>> crypt.crypt('test','$1$VFvON1xK$')
'$1SoNol0Ye6Xk'

Linux:

>>> import crypt
>>> crypt.crypt('test','$1$VFvON1xK$')
'$1$VFvON1xK$SboCDZGBieKF1ns2GBfY50'

From reading the pydoc for crypt, I saw it uses an OS-specific crypt implementation, so I also tested the following code in both systems with the same results as Python:

#include <unistd.h>

int main() {
        char *des = crypt("test","$1$VFvON1xK$ls4Zz4XTEuVI.1PnYm28.1");
        puts(des);
}

How can I have OS X’s crypt() implementation generate the same results as Linux crypt()?
And why isn’t that covered by the Python implementation (as I would expect from such cases for cross-platform deployment)?

  • 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-13T09:35:03+00:00Added an answer on June 13, 2026 at 9:35 am

    This is because Linux’s glibc handles passwords differently – the salt of the password on Linux corresponds to the type of hash that it generates. OSX crypt() is plain-old DES encryption, (which is horrible).

    glibc supports a variety of hash algorithms (MD5, Blowfish, SHA-256, etc).

    If we take a look at the crypt.3 manpage, we can see:

       If salt is a character string starting with the characters "$id$" followed by
       a string terminated by "$":
    
              $id$salt$encrypted
    
       then instead of using the DES machine, id identifies the encryption method
       used and this then determines how the rest of the password string is
       interpreted.  The following values of id are supported:
    
              ID  | Method
              ---------------------------------------------------------
              1   | MD5
              2a  | Blowfish (not in mainline glibc; added in some
                  | Linux distributions)
              5   | SHA-256 (since glibc 2.7)
              6   | SHA-512 (since glibc 2.7)
    

    So, given that information.. lets take your password from the second example using Linux’s crypt

    $1$VFvON1xK$SboCDZGBieKF1ns2GBfY50' ('test', encrypted with salt=VFvON1xK)
    
    
    1                       == MD5
    VFvON1xK                == Salt
    SboCDZGBieKF1ns2GBfY50  == Hashed password
    

    Luckily for you, there is a cross-platform solution for this, passlib.hash.md5_crypt.

    Here’s how you’d use it:

    from passlib.hash import md5_crypt
    hash = md5_crypt.encrypt("test",salt="VFvON1xK")
    print hash
    

    When run on Linux or OSX, produces the glibc friendly password hash of:

    $1$VFvON1xK$SboCDZGBieKF1ns2GBfY50
    

    Identical to the original produced on the Linux machine.

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

Sidebar

Related Questions

I have a Gunicorn server running a Django application which has a tendency to
I have a Django application which takes the lat/lon from a user's coordinates via
I have a user registration form in my Django application which collects additional data
i have this Django application in which when user request for localhost:8000/time/ ,it is
I have a flow in my django application in which I redirect the user
I would like to deplay a django application/project, which i have created within Aptana.
HI I have a django application running on app engine and I want to
I have a django application which has one main table/model which references various 'lookup'
I have a Django application which sometimes needs to send some data through TCP
I have a Django application which edits a database table, which another application polls

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.