Crate djangohashers

source ·
Expand description

A Rust port of the password primitives used in Django Project.

Django’s django.contrib.auth.models.User class has a few methods to deal with passwords, like set_password() and check_password(); DjangoHashers implements the primitive functions behind that methods. All Django’s built-in hashers are supported.

This library was conceived for Django integration, but is not limited to it; you can use the password hash algorithm in any Rust project (or FFI integration), since its security model is already battle-tested.

Structs§

  • Hasher that uses the Argon2 function (new in Django 1.10).
  • Hasher that uses the bcrypt key-derivation function without password padding.
  • Hasher that uses the bcrypt key-derivation function with the password padded with SHA256.
  • Hasher that uses the UNIX’s crypt(3) hash function.
  • Abstraction that exposes the functions that generates passwords compliant with different Django versions.
  • Hasher that uses the MD5 hashing function over the salted password.
  • Hasher that uses the PBKDF2 key-derivation function with the SHA256 hashing algorithm.
  • Hasher that uses the PBKDF2 key-derivation function with the SHA1 hashing algorithm.
  • Hasher that uses the SHA1 hashing function over the salted password.
  • Hasher that uses the Scrypt function (new in Django 4.0).
  • Hasher that uses the MD5 hashing function with no salting.
  • Hasher that uses the SHA1 hashing function with no salting.

Enums§

Traits§

  • Hasher abstraction, providing methods to encode and verify hashes.

Functions§

  • Verifies a password against an encoded hash, returns a Result.
  • Verifies a password against an encoded hash, returns a boolean, even in case of error.
  • Verifies if an encoded hash is properly formatted before check it cryptographically.
  • Based on the current Django version, generates an encoded hash given only a password, uses a random salt and the PBKDF2 algorithm.
  • Core function that generates all combinations of passwords:
  • Based on the current Django version, generates an encoded hash given a password and algorithm, uses a random salt.
  • Based on the current Django version, generates an encoded hash given a complete set of parameters: password, salt and algorithm.