module

Krikri::PluginHelpers::MysqlSaltedHash

ansible.mysql 5.2.0's implementations/mysql/hash.py - the SHA-crypt-derived storage format MySQL's caching_sha2_password / sha256_password plugins store, made DETERMINISTIC by the module's salt: parameter ($A$005$<salt><base64 digest>, hexed for the AS 0x... CREATE/ALTER form). Real relies on the determinism for idempotency: user.py compares mysql.user.authentication_string against mysql_sha256_password_hash(plugin_auth_string, salt) before deciding whether an ALTER is needed (wiggels.snipeit's own "Create snipeit user" task, round 1500042, reported changed on every warm run without this - the server's own random-salt hash never equals the plaintext it was asked to store).

The digest walk is Drepper's SHA-crypt exactly as the Python port writes it (5 * 1000 iterations), pinned against that Python implementation's own output in test/unit/mysql_salted_hash_test.cr.

Instance methods

hash(password : String, salt : String) : String

The stored (raw) hash for a (password, salt) pair. The salt is the module's validated 20-character value; the caller's salt check ("salt must be 20 characters long") runs first in real, so no length guard is repeated here.

Source
hash_hex(password : String, salt : String) : String

The same bytes upper-cased as hex - the literal MySQL accepts after IDENTIFIED WITH <plugin> AS 0x.

Source