2010-08-23 19:10:28 -05:00
|
|
|
//
|
|
|
|
// MGMSHA256.h
|
|
|
|
//
|
|
|
|
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
|
|
|
// No Copyright Claimed. Public Domain.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef _MD_SHA256
|
|
|
|
#define _MD_SHA256
|
|
|
|
|
|
|
|
#ifdef __NEXT_RUNTIME__
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
|
|
|
extern NSString * const MDNSHA256;
|
|
|
|
|
|
|
|
@interface NSString (MGMSHA256)
|
|
|
|
- (NSString *)SHA256;
|
|
|
|
- (NSString *)pathSHA256;
|
|
|
|
@end
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-08-09 22:54:43 -05:00
|
|
|
extern const struct MGMHashDescription SHA256Desc;
|
|
|
|
|
2010-08-23 19:10:28 -05:00
|
|
|
char *SHA256String(const char *string, int length);
|
|
|
|
char *SHA256File(const char *path);
|
|
|
|
|
|
|
|
#define SHA256Length 32
|
2013-08-09 22:54:43 -05:00
|
|
|
#define SHA256BufferSize 64
|
2010-08-23 19:10:28 -05:00
|
|
|
|
|
|
|
struct SHA256Context {
|
2013-08-09 22:54:43 -05:00
|
|
|
uint64_t length;
|
|
|
|
uint32_t state[8], curlen;
|
|
|
|
unsigned char buf[SHA256BufferSize];
|
2010-08-23 19:10:28 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
void SHA256Init(struct SHA256Context *context);
|
|
|
|
void SHA256Update(struct SHA256Context *context, const unsigned char *buf, unsigned int len);
|
|
|
|
void SHA256Final(unsigned char digest[SHA256Length], struct SHA256Context *context);
|
2013-08-09 22:54:43 -05:00
|
|
|
void SHA256Transform(struct SHA256Context *context, unsigned char *buf);
|
|
|
|
int SHA256Test();
|
2010-08-23 19:10:28 -05:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|