This functions encodes a password in the same format as django. You can set the auth_user.password column with the result of this function:
update `auth_user`.`password`
set `password` = django_password('secret')
where id = 1234;
1 2 3 4 5 6 7 8 9 10 11 12 | DELIMITER //
CREATE FUNCTION django_password(
pass VARCHAR(32)
) RETURNS VARCHAR(128)
DETERMINISTIC
BEGIN
DECLARE salt char(5);
DECLARE hash VARCHAR(40);
SET salt = MID(RAND(), 3, 5);
SET hash = SHA(CONCAT(salt, pass));
RETURN CONCAT('sha1$', salt, '$', hash);
END//
|
More like this
- create_template_postgis-ubuntu_lucid by clawlor 14 years ago
- PostgreSQL fulltext with language translations by diverman 14 years, 1 month ago
- Drop all tables in MySQL database by mpasternacki 14 years, 8 months ago
- grep and delete sqlite tables by kifkif 14 years, 10 months ago
- Substitute hyphens with spaces to enale URLs to reference to multi-word tags by miernik 14 years, 11 months ago
Comments
Note the deterministic behaviour from the manual:
#
How would you make use of this inside of Django (and Django Admin) i.e. where would you add the SQL?
#
Please login first before commenting.