Skip to content

Commit e8c30be

Browse files
authored
WebServer: use MD5Builder instead of mbed
1 parent 02e31b4 commit e8c30be

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

libraries/WebServer/src/WebServer.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "WebServer.h"
3030
#include "FS.h"
3131
#include "detail/RequestHandlersImpl.h"
32-
#include "mbedtls/md5.h"
32+
#include "MD5Builder.h"
3333

3434

3535
static const char AUTHORIZATION_HEADER[] = "Authorization";
@@ -119,23 +119,11 @@ String WebServer::_extractParam(String& authReq,const String& param,const char d
119119
}
120120

121121
static String md5str(String &in){
122-
char out[33] = {0};
123-
mbedtls_md5_context _ctx;
124-
uint8_t i;
125-
uint8_t * _buf = (uint8_t*)malloc(16);
126-
if(_buf == NULL)
127-
return String(out);
128-
memset(_buf, 0x00, 16);
129-
mbedtls_md5_init(&_ctx);
130-
mbedtls_md5_starts_ret(&_ctx);
131-
mbedtls_md5_update_ret(&_ctx, (const uint8_t *)in.c_str(), in.length());
132-
mbedtls_md5_finish_ret(&_ctx, _buf);
133-
for(i = 0; i < 16; i++) {
134-
sprintf(out + (i * 2), "%02x", _buf[i]);
135-
}
136-
out[32] = 0;
137-
free(_buf);
138-
return String(out);
122+
MD5Builder md5 = MD5Builder();
123+
md5.begin();
124+
md5.add(in);
125+
md5.calculate();
126+
return md5.toString();
139127
}
140128

141129
bool WebServer::authenticate(const char * username, const char * password){

0 commit comments

Comments
 (0)