Last active
August 29, 2015 14:01
-
-
Save mundry/f8abe29f507345b5223e to your computer and use it in GitHub Desktop.
Generate the Sha1 of a string using OpenSSL.
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 <stdio.h> | |
#include <string.h> | |
#include <openssl/sha.h> | |
// gcc -o sha1 sha1.c -lcrypto | |
int main(void) { | |
const unsigned char ibuf[] = "compute sha1"; | |
unsigned char obuf[20]; | |
SHA1(ibuf, strlen(ibuf), obuf); | |
int i; | |
for (i = 0; i < 20; i++) { | |
printf("%02x", obuf[i]); | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment