Python implementation of sha512_crypt.c

ε祈祈猫儿з 提交于 2019-12-23 05:48:09

问题


I'm looking for a 100% pure Python implementation of sha512_crypt.c as taken from http://www.akkadia.org/drepper/SHA-crypt.txt.

I'm learning Python. I want to understand the code (and compare it to the C code, etc.). I don't know enough Python to write it myself -- even if I did, I wouldn't trust myself to get it right. I don't have that expertise. So please don't answer this question by telling me to go write the code myself. That's not my question. I am looking for an existing 100% Python implementation that gives the same output as the original sha512_crypt.c written by Ulrich Drepper.

Just to be sure my question is clear, answers I'm looking for are probably either:

  1. "I know for sure that a 100% Python implementation of that C code doesn't exist."

  2. "Here is the link to the Python code that you can download."

(Even though I'm not asking for help writing specific code, I was told to post here as a result of a meta discussion. This question is, after all, about studying Python code.)

BTW, I know there is a Java implementation here: ftp://ftp.arlut.utexas.edu/java_hashes/

I'm looking for the Python equivalent.

Thank you.

UPDATE: james-mills answered the question for me. But today I just learned about Nullege: A Search Engine for Python source code
http://www.nullege.com/ That could come in handy in the future.

I also learned that startpage.com will accept "filetype:py" as a search term and it returns some good results. Unfortunately, I tried the same with duckduckgo and it didn't return any results.


回答1:


Check out passlib it seems to have a pure Python implemtnation of SHA512 crypt that it falls back to:

This class will use the first available of two possible backends: stdlib crypt(), if the host OS supports SHA512-Crypt (most Linux systems). a pure python implementation of SHA512-Crypt built into passlib. You can see which backend is in use by calling the get_backend() method.

Found the source code: https://code.google.com/p/passlib/source/browse/passlib/handlers/sha2_crypt.py




回答2:


Its a bit subjective because you have so many choices, but try this: http://google.com/search?q="sha512_crypt"+filetype:py. Notice the quotes around the filename to ensure you get an exact match (Google will treat the underscore as a space otherwise).

I'm not familiar with Drepper's work or Python, so I could not say if any are any exact matches.



来源:https://stackoverflow.com/questions/21082483/python-implementation-of-sha512-crypt-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!