From: Stefan Fritsch Date: Mon, 18 Mar 2013 21:13:31 +0000 (+0000) Subject: simplify code by using ap_bin2hex() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90d6e1334135383b26c4b529790e28d070f6405e;p=thirdparty%2Fapache%2Fhttpd.git simplify code by using ap_bin2hex() git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1458003 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index e5858c402a5..8dcab1e8dc9 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -1038,21 +1038,15 @@ static const char *sha1_func(ap_expr_eval_ctx_t *ctx, const void *data, { apr_sha1_ctx_t context; apr_byte_t sha1[APR_SHA1_DIGESTSIZE]; - char *hash, *out; - const char *hex = "0123456789abcdef"; - int idx; + char *out; - hash = out = apr_palloc(ctx->p, APR_SHA1_DIGESTSIZE*2+1); + out = apr_palloc(ctx->p, APR_SHA1_DIGESTSIZE*2+1); apr_sha1_init(&context); apr_sha1_update(&context, arg, strlen(arg)); apr_sha1_final(sha1, &context); - for (idx = 0; idx < APR_SHA1_DIGESTSIZE; idx++) { - *hash++ = hex[sha1[idx] >> 4]; - *hash++ = hex[sha1[idx] & 0xF]; - } - *hash++ = '\0'; + ap_bin2hex(sha1, APR_SHA1_DIGESTSIZE, out); return out; }