I hunted around in the shadow-utils source and traced it back to a crypt function which I was unable to locate the source
I found some python code which I don't entirely understand. It appears to be something along the lines of
password+salt+password+???
The source is here near the bottom. Can someone translate?
I'll take a low level language any day. Python may be fast but it's confusing.