Skip to main content
6 of 9
Added second hash example
JohnMark13
  • 3.7k
  • 1
  • 17
  • 27

Verify Python Passlib generated PBKDF2 SHA512 Hash in .NET

I am migrating a platform which used Passlib 1.6.2 to generate password hashes. The code to encrypt the password is (hash is called with default value for rounds):

from passlib.hash import pbkdf2_sha512 as pb def hash(cleartext, rounds=10001): return pb.encrypt(cleartext, rounds=rounds) 

The output format looks like (for the password "Patient3" (no quotes)):

$pbkdf2 - sha512$10001$0dr7v7eWUmptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b5746rghZ8WrgEjDpvXG5hLz1UeNLzgFa81Drbx2b7.hg 

And "Testing123"

$pbkdf2-sha512$10001$2ZuTslYKAYDQGiPkfA.B8A$ChsEXEjanEToQcPJiuVaKk0Ls3n0YK7gnxsu59rxWOawl/iKgo0XSWyaAfhFV0.Yu3QqfehB4dc7yGGsIW.ARQ 

I can see that represents:

  • Algorithm SHA512
  • Iterations 10001
  • Salt 0dr7v7eWUmptrfW.9z6HkA (possibly)

I found passlib.net which looks a bit like an abandoned beta and it uses '$6$' for the algorithm. I could not get it to verify the password. I tried changing the algorithm to $6$ but I suspect that in effect changes the salt as well.

I also tried using PWDTK with various values for salt and hash, but it may have been I was splitting the shadow password incorrectly, or supplying $ in some places where I should not have been.

Is there any way to verify a password against this hash value in .NET? Or another solution which does not involve either a Python proxy or getting users to resupply a password?

JohnMark13
  • 3.7k
  • 1
  • 17
  • 27