diff options
author | yzrh <yzrh@noema.org> | 2023-01-01 10:44:27 +0000 |
---|---|---|
committer | yzrh <yzrh@noema.org> | 2023-01-01 11:11:56 +0000 |
commit | 9019a184494e6fc220bcc1eb8f47f33fe0f3e506 (patch) | |
tree | 1615ce42fec0e7e84d86178f08ae6fc2b55ccb7c /src/md5.c | |
parent | a18de8f2ef4be4a92b2e08161ce4b8f164ad4f7f (diff) | |
download | melon-9019a184494e6fc220bcc1eb8f47f33fe0f3e506.tar.gz melon-9019a184494e6fc220bcc1eb8f47f33fe0f3e506.tar.zst |
Split md5 function.
Signed-off-by: yzrh <yzrh@noema.org>
Diffstat (limited to 'src/md5.c')
-rw-r--r-- | src/md5.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/md5.c b/src/md5.c new file mode 100644 index 0000000..e5ab95e --- /dev/null +++ b/src/md5.c @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023, yzrh <yzrh@noema.org> + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include <stdlib.h> + +#include <openssl/md5.h> + +int +strmd5(unsigned char **dst, int *dst_size, + const unsigned char * restrict src, int src_size) +{ + *dst_size = MD5_DIGEST_LENGTH; + *dst = malloc(*dst_size); + + if (*dst == NULL) + return 1; + + MD5(src, src_size, *dst); + + return 0; +} |