Created
May 10, 2011 08:43
-
-
Save ytakano/964119 to your computer and use it in GitHub Desktop.
sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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