]> granicus.if.org Git - apache/commitdiff
add md5 function, too
authorStefan Fritsch <sf@apache.org>
Mon, 18 Mar 2013 21:16:18 +0000 (21:16 +0000)
committerStefan Fritsch <sf@apache.org>
Mon, 18 Mar 2013 21:16:18 +0000 (21:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1458004 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/expr.xml
server/util_expr_eval.c

index 50cdf9b84cecd6883f89b2869a940b521112dcb8..cc6266e406cc6b19f1320f94010515823211efac 100644 (file)
@@ -481,6 +481,9 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <tr><td><code>unbase64</code></td>
         <td>Decode base64 encoded string, return truncated string if 0x00 is
             found</td><td></td></tr>
+    <tr><td><code>md5</code></td>
+        <td>Hash the string using MD5, then encode the hash with hexadecimal
+            encoding</td><td></td></tr>
     <tr><td><code>sha1</code></td>
         <td>Hash the string using SHA1, then encode the hash with hexadecimal
             encoding</td><td></td></tr>
index 8dcab1e8dc943c82ebdac1b4dfa040538f231c76..d99212001f90d12c82ad2075bd7d4e69e7698de3 100644 (file)
@@ -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}
 };