This is not technically a database question, but about the innards of Postgres's pgcrypto extension.The documentation says

The algorithms in crypt() differ from the usual MD5 or SHA1 hashing algorithms in the following respects:

I would like to know how/where might I be able to find the details of the hashing algorithms.

Ideally, I would like to compare the algorithms of pgcrypto with the regular versions of the algorithms.

  • The docs are describing the difference between password hashing and other hashing not suitable for password. Not the difference between their password hashing and other's password hashing.
    – jjanes
    Jan 15, 2023 at 21:48
  • 1
    This is very much a database question. Password security inter alia is integral to database systems and questions related to RDBMS crypto libraries are very much on topic! Mostly directed at the person who downvoted without leaving a comment!
    – Vérace
    Jan 16, 2023 at 10:26

1 Answer 1


Since Postgresql is open source, you can find the code of hashing algorithms easily.

Basically, pg_crypt function calls px_crypt function which picks algoritm and calls related hashing function for example px_crypt_md5 which is imported from FreeBSD source.

  • 1
    I think it's the modifications that PostgreSQL may have made to the algorithms (as outlined in the link) that the OP is interested in, rather than the "raw" algorithms themselves - at least, that's what I get from the question!
    – Vérace
    Jan 15, 2023 at 18:17
  • I tough the same but still this answer may help him
    – Sahap Asci
    Jan 15, 2023 at 18:39
  • 1
    @dakini You haven't specified the reference implementations, so how can anyone describe how pgcrypto differs from them?
    – jjanes
    Jan 17, 2023 at 18:18
  • 1
    @dakini each crpty function has a loop to waste some time . for example there is a loop (for(i = 0; i < 1000; i++) ) in md5 and another one in sha512 (for (cnt = 0; cnt < rounds; ++cnt))
    – Sahap Asci
    Jan 19, 2023 at 20:04
  • 1
    @dakini the answer already has the code link for px_crypt_md5 just check the folder for others
    – Sahap Asci
    Jan 20, 2023 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.