Skip to content

Instantly share code, notes, and snippets.

@iaoedsz2008
Created October 3, 2019 15:16
Show Gist options
  • Save iaoedsz2008/0e0336039dd916d8d858976f2389e16d to your computer and use it in GitHub Desktop.
Save iaoedsz2008/0e0336039dd916d8d858976f2389e16d to your computer and use it in GitHub Desktop.
#include <openssl/md5.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
MD5_CTX c;
unsigned char data[] = "your data";
int len = strlen(data);
unsigned char md5[MD5_DIGEST_LENGTH] = {0};
MD5_Init(&c);
MD5_Update(&c, data, len);
MD5_Final(md5, &c);
for (int i = 0; i < MD5_DIGEST_LENGTH; ++i)
printf("%02x", md5[i]);
puts("");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment