return str_c(hash);
}
+static const char *
+m_str_newhash(const char *str, struct var_expand_context *ctx)
+{
+ string_t *hash = t_str_new(20);
+ unsigned char result[MD5_RESULTLEN];
+ unsigned int value;
+
+ md5_get_digest(str, strlen(str), result);
+ memcpy(&value, result, sizeof(value));
+
+ if (ctx->width != 0) {
+ value %= ctx->width;
+ ctx->width = 0;
+ }
+
+ str_printfa(hash, "%x", value);
+ while ((int)str_len(hash) < ctx->offset)
+ str_insert(hash, 0, "0");
+ ctx->offset = 0;
+
+ return str_c(hash);
+}
+
static const char *
m_str_md5(const char *str, struct var_expand_context *ctx ATTR_UNUSED)
{
{ 'X', m_str_hex },
{ 'R', m_str_reverse },
{ 'H', m_str_hash },
+ { 'N', m_str_newhash },
{ 'M', m_str_md5 },
{ 'D', m_str_ldap_dn },
{ 'T', m_str_trim },