Consolidated ASP Classic MVC framework from best components
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

34 lignes
1.2KB

  1. <%
  2. '=======================================================================================================================
  3. ' PASSWORD HELPERS (native G3CRYPTO: bcrypt)
  4. '=======================================================================================================================
  5. ' Replaces the old PowerShell/SHA-256 shell-out, which cannot run on AxonASP/Linux and put the password on a
  6. ' command line. Stored hashes are bcrypt ("$2a$..."), so previously stored SHA-256 hashes will not verify; reset them.
  7. Function HashPassword(password)
  8. Dim crypto
  9. Set crypto = Server.CreateObject("G3CRYPTO")
  10. HashPassword = crypto.HashPassword(password)
  11. Set crypto = Nothing
  12. End Function
  13. ' Returns True when username exists in Users and password matches its stored hash.
  14. Function CheckPassword(username, password)
  15. Dim crypto, rs, storedHash
  16. CheckPassword = False
  17. Set rs = DAL().Query("SELECT PasswordHash FROM Users WHERE UserName = ?", username)
  18. If rs.EOF Then
  19. rs.Close
  20. Exit Function
  21. End If
  22. storedHash = "" & rs("PasswordHash")
  23. rs.Close
  24. Set rs = Nothing
  25. Set crypto = Server.CreateObject("G3CRYPTO")
  26. CheckPassword = crypto.VerifyPassword(password, storedHash)
  27. Set crypto = Nothing
  28. End Function
  29. %>

Powered by TurnKey Linux.