Skip to content

Instantly share code, notes, and snippets.

@mundry
Last active August 29, 2015 14:01
Show Gist options
  • Save mundry/f8abe29f507345b5223e to your computer and use it in GitHub Desktop.
Save mundry/f8abe29f507345b5223e to your computer and use it in GitHub Desktop.
Generate the Sha1 of a string using OpenSSL.
#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