885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bosebool mail_user_hash(const char *username, const char *format,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose /* fast path */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose /* almost as fast path */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose { 'd', i_strchr_to_next(username, '@'), "domain" },
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose md5_get_digest(str_data(str), str_len(str), md5);
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose for (i = 0; i < sizeof(hash); i++)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose /* Make sure we don't return the hash as 0, since it's often
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose treated in a special way that won't work well. For example
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose trying to insert it into a hash table will assert-crash. */