Skip to content

Instantly share code, notes, and snippets.

@ytakano
Created May 10, 2011 08:43
Show Gist options
  • Save ytakano/964119 to your computer and use it in GitHub Desktop.
Save ytakano/964119 to your computer and use it in GitHub Desktop.
sha1
#include <openssl/evp.h>
#include <openssl/rand.h>
void
sha1(char *buf, int len) {
EVP_MD_CTX md_ctx;
unsigned int md_len;
unsigned char md_value[EVP_MAX_MD_SIZE];
EVP_MD_CTX_init(&md_ctx);
EVP_DigestInit_ex(&md_ctx, EVP_sha1(), NULL);
EVP_DigestUpdate(&md_ctx, buf, len);
EVP_DigestFinal_ex(&md_ctx, md_value, &md_len);
EVP_MD_CTX_cleanup(&md_ctx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment