Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <libsha1.h>
- void printByte(unsigned char);
- int main(int argc, char *argv[])
- {
- unsigned char hash[20];
- int i;
- #ifndef LIBSHA1_NO_CTX
- sha1_ctx ctx;
- #endif
- if (argc != 2)
- {
- fprintf(stderr, "Usage: %s string\n", argv[0]);
- return 1;
- }
- #ifdef LIBSHA1_NO_CTX
- sha1(hash, argv[1], strlen(argv[1]));
- #else
- sha1_begin(&ctx);
- sha1_hash(argv[1], strlen(argv[1]), &ctx);
- sha1_end(hash, &ctx);
- #endif
- for (i=0; i<5; i++) printByte(byte); printf("\n");
- return 0;
- }
- void printByte(unsigned char byte)
- {
- const char *digits = "0123456789abcdef";
- printf("%c%c", digits[byte / 16], digits[byte % 16]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement