Skip to content

Commit

Permalink
Add Function for Zero in Byte Arrays
Browse files Browse the repository at this point in the history
make_hash(char *arg,size_t size)

Now you can create MD5 from UTF-16,Bytestreams and other Rawbytes with
fixed size. strlen stops at zero.
  • Loading branch information
schuppeste committed May 16, 2017
1 parent 6de55b6 commit afbc926
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions MD5.cpp
Expand Up @@ -287,4 +287,13 @@ unsigned char* MD5::make_hash(char *arg)
MD5Final(hash, &context);
return hash;
}
unsigned char* MD5::make_hash(char *arg,size_t size)
{
MD5_CTX context;
unsigned char * hash = (unsigned char *) malloc(16);
MD5Init(&context);
MD5Update(&context, arg, size);
MD5Final(hash, &context);
return hash;
}

1 change: 1 addition & 0 deletions MD5.h
Expand Up @@ -41,6 +41,7 @@ class MD5
public:
MD5();
static unsigned char* make_hash(char *arg);
static unsigned char* make_hash(char *arg,size_t size);
static char* make_digest(const unsigned char *digest, int len);
static const void *body(void *ctxBuf, const void *data, size_t size);
static void MD5Init(void *ctxBuf);
Expand Down

0 comments on commit afbc926

Please sign in to comment.