File tree Expand file tree Collapse file tree 1 file changed +7
-18
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +7
-18
lines changed
Original file line number Diff line number Diff line change 24
24
#include < Arduino.h>
25
25
#include < esp32-hal-log.h>
26
26
#include < libb64/cencode.h>
27
+ #include " esp_random.h"
27
28
#include " WiFiServer.h"
28
29
#include " WiFiClient.h"
29
30
#include " WebServer.h"
30
31
#include " FS.h"
31
32
#include " detail/RequestHandlersImpl.h"
32
- #include " mbedtls/md5 .h"
33
+ #include " MD5Builder .h"
33
34
34
35
35
36
static const char AUTHORIZATION_HEADER[] = " Authorization" ;
@@ -119,23 +120,11 @@ String WebServer::_extractParam(String& authReq,const String& param,const char d
119
120
}
120
121
121
122
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);
123
+ MD5Builder md5 = MD5Builder ();
124
+ md5.begin ();
125
+ md5.add (in);
126
+ md5.calculate ();
127
+ return md5.toString ();
139
128
}
140
129
141
130
bool WebServer::authenticate (const char * username, const char * password){
You can’t perform that action at this time.
0 commit comments