File indexing completed on 2024-06-23 03:58:16
0001 #include "sha1.h" 0002 #include <stdio.h> 0003 #include <stdlib.h> 0004 #include <string.h> 0005 0006 int main() 0007 { 0008 SHA1 *sha1; 0009 unsigned char data[] = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; 0010 unsigned long et[] = {0x11223344}; 0011 int rc; 0012 0013 printf("%d: 0x11 == %d and 0x44 == %d\n", ((unsigned char *)et)[0], 0x11, 0x44); 0014 sha1 = new SHA1(); 0015 0016 if (!sha1->readyToGo()) { 0017 printf("Error: not ready to go!\n"); 0018 return -1; 0019 } 0020 0021 printf("About to process [%s]\n", data); 0022 rc = sha1->process(data, strlen((char *)data)); 0023 0024 if (rc != strlen((char *)data)) { 0025 printf("Error processing the data. rc=%d\n", rc); 0026 } else { 0027 printf("Done.\n"); 0028 } 0029 0030 const unsigned char *res = sha1->hash(); 0031 0032 if (res) { 0033 for (int i = 0; i < 20; i++) { 0034 printf("%.2X", *res++); 0035 if (i > 0 && (i - 1) % 2 == 0) { 0036 printf(" "); 0037 } 0038 } 0039 printf("\n"); 0040 } else { 0041 printf("Error - getHash() returned NULL!\n"); 0042 } 0043 0044 delete sha1; 0045 }