From: Stefan Fritsch Date: Mon, 18 Mar 2013 21:16:18 +0000 (+0000) Subject: add md5 function, too X-Git-Tag: 2.5.0-alpha~5659 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f358e7e1708ef19c06bd288a254234759e4fdd3;p=apache add md5 function, too git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1458004 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/expr.xml b/docs/manual/expr.xml index 50cdf9b84c..cc6266e406 100644 --- a/docs/manual/expr.xml +++ b/docs/manual/expr.xml @@ -481,6 +481,9 @@ listfunction ::= listfuncname "(" word ")" unbase64 Decode base64 encoded string, return truncated string if 0x00 is found + md5 + Hash the string using MD5, then encode the hash with hexadecimal + encoding sha1 Hash the string using SHA1, then encode the hash with hexadecimal encoding diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index 8dcab1e8dc..d99212001f 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -25,6 +25,7 @@ #include "http_request.h" #include "ap_provider.h" #include "util_expr_private.h" +#include "util_md5.h" #include "apr_lib.h" #include "apr_fnmatch.h" @@ -1051,6 +1052,13 @@ static const char *sha1_func(ap_expr_eval_ctx_t *ctx, const void *data, return out; } +static const char *md5_func(ap_expr_eval_ctx_t *ctx, const void *data, + const char *arg) +{ + return ap_md5(ctx->p, (const unsigned char *)arg); +} + + #define MAX_FILE_SIZE 10*1024*1024 static const char *file_func(ap_expr_eval_ctx_t *ctx, const void *data, char *arg) @@ -1633,6 +1641,7 @@ static const struct expr_provider_single string_func_providers[] = { { base64_func, "base64", NULL, 0 }, { unbase64_func, "unbase64", NULL, 0 }, { sha1_func, "sha1", NULL, 0 }, + { md5_func, "md5", NULL, 0 }, { NULL, NULL, NULL} };