encrypt_password - quart_imp.auth

from quart_imp.auth import encrypt_password
encrypt_password(
    password: str,
    salt: str,
    encryption_level: int = 512,
    pepper_length: int = 1,
    pepper_position: t.Literal["start", "end"] = "end"
) -> str

For use in password hashing.

To be used alongside the quart_imp.auth / authenticate_password function.

Takes the plain password, applies a pepper, salts it, then produces a digested sha512 or sha256 if specified.

Can set the encryption level to 256 or 512, defaults to 512.

Can set the pepper length, defaults to 1. Max is 3.

Can set the pepper position, "start" or "end", defaults to "end".

Note:

Encryption Scenario:

Plain password: "password"
Generated salt: "^%$*" (randomly generated)
Generated pepper (length 1): "A" (randomly generated)
Pepper position: "end"
  1. Pepper is added to the end of the plain password: "passwordA"
  2. Salt is added to the end of the peppered password: "passwordA^%$*"
  3. Password is hashed: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0..."
  4. Salt and hashed password are then stored in the database.