💾 Archived View for gmi.noulin.net › gitRepositories › sha256 › file › sha256.h.gmi captured on 2023-01-29 at 13:17:40. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
sha256.h (1321B)
1 /********************************************************************* 2 * Filename: sha256.h 3 * Author: Brad Conte (brad AT bradconte.com) 4 * Copyright: 5 * Disclaimer: This code is presented "as is" without any guarantees. 6 * Details: Defines the API for the corresponding SHA1 implementation. 7 *********************************************************************/ 8 9 #ifndef SHA256_H 10 #define SHA256_H 11 12 /** 13 * sha256S returns the hash in the form of a hex string 14 */ 15 char *sha256S(const char *bufferToHash); 16 17 /*************************** HEADER FILES ***************************/ 18 #include <stddef.h> 19 20 /****************************** MACROS ******************************/ 21 #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest 22 23 /**************************** DATA TYPES ****************************/ 24 typedef unsigned char BYTE; // 8-bit byte 25 typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines 26 27 typedef struct { 28 BYTE data[64]; 29 WORD datalen; 30 unsigned long long bitlen; 31 WORD state[8]; 32 } SHA256_CTX; 33 34 /*********************** FUNCTION DECLARATIONS **********************/ 35 void sha256_init(SHA256_CTX *ctx); 36 void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len); 37 void sha256_final(SHA256_CTX *ctx, BYTE hash[]); 38 39 #endif // SHA256_H