From 0de85dd736668cf7a1b930c9e74fed0b45e5b1b4 Mon Sep 17 00:00:00 2001 From: wangyu- Date: Mon, 18 Sep 2017 06:51:38 -0500 Subject: [PATCH] optimize md5 code --- lib/md5.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/md5.c b/lib/md5.c index 0ccb028..0f6ddd3 100755 --- a/lib/md5.c +++ b/lib/md5.c @@ -302,11 +302,15 @@ void md5_finish( md5_context *ctx, unsigned char output[16] ) */ void md5( const unsigned char *input, size_t ilen, unsigned char output[16] ) { - md5_context ctx; - - md5_init( &ctx ); + static md5_context ctx; + static int done=0; + if(done==0) + { + md5_init( &ctx ); + done=1; + } md5_starts( &ctx ); md5_update( &ctx, input, ilen ); md5_finish( &ctx, output ); - md5_free( &ctx ); + //md5_free( &ctx ); }