_info (1387B)
1 #include "config.h" 2 #include <stdio.h> 3 #include <string.h> 4 5 /** 6 * crypto/sha256 - implementation of SHA-2 with 256 bit digest. 7 * 8 * This code is either a wrapper for openssl (if CCAN_CRYPTO_SHA256_USE_OPENSSL 9 * is defined) or an open-coded implementation based on Bitcoin's. 10 * 11 * License: BSD-MIT 12 * Maintainer: Rusty Russell <rusty@rustcorp.com.au> 13 * 14 * Example: 15 * #include <ccan/crypto/sha256/sha256.h> 16 * #include <err.h> 17 * #include <stdio.h> 18 * #include <string.h> 19 * 20 * // Simple demonstration: idential strings will have the same hash, but 21 * // two different strings will not. 22 * int main(int argc, char *argv[]) 23 * { 24 * struct sha256 hash1, hash2; 25 * 26 * if (argc != 3) 27 * errx(1, "Usage: %s <string1> <string2>", argv[0]); 28 * 29 * sha256(&hash1, argv[1], strlen(argv[1])); 30 * sha256(&hash2, argv[2], strlen(argv[2])); 31 * printf("Hash is %s\n", memcmp(&hash1, &hash2, sizeof(hash1)) 32 * ? "different" : "same"); 33 * return 0; 34 * } 35 */ 36 int main(int argc, char *argv[]) 37 { 38 /* Expect exactly one argument */ 39 if (argc != 2) 40 return 1; 41 42 if (strcmp(argv[1], "depends") == 0) { 43 printf("ccan/compiler\n"); 44 printf("ccan/endian\n"); 45 return 0; 46 } 47 48 if (strcmp(argv[1], "testdepends") == 0) { 49 printf("ccan/str/hex\n"); 50 return 0; 51 } 52 53 if (strcmp(argv[1], "libs") == 0) { 54 #ifdef CCAN_CRYPTO_SHA256_USE_OPENSSL 55 printf("crypto\n"); 56 #endif 57 return 0; 58 } 59 60 return 1; 61 }