Skip to content

Commit

Permalink
Easier md5 function
Browse files Browse the repository at this point in the history
  • Loading branch information
malwarepad committed Nov 30, 2024
1 parent 3ddf0b2 commit 0af7c7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/kernel/include/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ extern void MD5_Init(MD5_CTX *ctx);
extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);

#define MD5_LEN (32 + 1)
void MD5_Simple(uint8_t *buff, int length, char *md5sum_out);

#endif
14 changes: 14 additions & 0 deletions src/kernel/utilities/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,17 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx) {
}

#endif

#include <malloc.h>
#include <system.h>
void MD5_Simple(uint8_t *buff, int length, char *md5sum_out) {
MD5_CTX ctx = {0};
MD5_Init(&ctx);
MD5_Update(&ctx, buff, length);

MD5_OUT md = {0};
MD5_Final((void *)&md, &ctx);
snprintf(md5sum_out, MD5_LEN, "%02x%02x%02x%02x", switch_endian_32(md.a),
switch_endian_32(md.b), switch_endian_32(md.c),
switch_endian_32(md.d));
}

0 comments on commit 0af7c7c

Please sign in to comment.