MGMMD Start
This commit is contained in:
commit
5670478176
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
build
|
||||
*.zip
|
||||
*.xcodeproj/*.pbxuser
|
||||
*.xcodeproj/*.mode*
|
||||
*.xcodeproj/*.perspective*
|
||||
*.xcodeproj/xcuserdata
|
||||
*.xcodeproj/project.xcworkspace/xcuserdata
|
51
Classes/MGMMD.h
Normal file
51
Classes/MGMMD.h
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// MGMMD.h
|
||||
// MGMMD
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 8/23/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MGMMD5.h"
|
||||
#import "MGMSHA1.h"
|
||||
#import "MGMSHA224.h"
|
||||
#import "MGMSHA256.h"
|
||||
#import "MGMSHA384.h"
|
||||
#import "MGMSHA512.h"
|
||||
|
||||
typedef enum {
|
||||
MDNULL = -1,
|
||||
MDMD5 = 0,
|
||||
MDSHA1 = 1,
|
||||
MDSHA224 = 2,
|
||||
MDSHA256 = 3,
|
||||
MDSHA384 = 4,
|
||||
MDSHA512 = 5,
|
||||
} MGMMDType;
|
||||
|
||||
@interface MGMMD : NSObject {
|
||||
MGMMDType algorithm;
|
||||
int algorithmLength;
|
||||
void *context;
|
||||
NSData *finalData;
|
||||
}
|
||||
+ (NSString *)stringHash:(NSString *)theString usingAlgorithm:(NSString *)theAlgorithm;
|
||||
+ (NSString *)fileHash:(NSString *)theFile usingAlgorithm:(NSString *)theAlgorithm;
|
||||
+ (NSString *)dataHash:(NSData *)theData usingAlgorithm:(NSString *)theAlgorithm;
|
||||
|
||||
+ (NSArray *)supportedAlgorithms;
|
||||
|
||||
+ (id)mdWithAlgorithm:(NSString *)theAlgorithm;
|
||||
- (id)initWithAlgorithm:(NSString *)theAlgorithm;
|
||||
|
||||
- (BOOL)updateWithString:(NSString *)theString;
|
||||
- (BOOL)updateWithFile:(NSString *)theFile;
|
||||
- (BOOL)updateWithData:(NSData *)theData;
|
||||
- (BOOL)updateWithBytes:(const char *)theBytes length:(int)theLength;
|
||||
|
||||
- (NSData *)finalData;
|
||||
- (const char *)finalBytes;
|
||||
- (const char *)finalStringHash;
|
||||
- (NSString *)finalHash;
|
||||
@end
|
225
Classes/MGMMD.m
Normal file
225
Classes/MGMMD.m
Normal file
@ -0,0 +1,225 @@
|
||||
//
|
||||
// MGMMD.m
|
||||
// MGMMD
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 8/23/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#import "MGMMD.h"
|
||||
#import "MGMMDTypes.h"
|
||||
|
||||
@implementation MGMMD
|
||||
+ (NSString *)stringHash:(NSString *)theString usingAlgorithm:(NSString *)theAlgorithm {
|
||||
MGMMD *md = [self mdWithAlgorithm:theAlgorithm];
|
||||
[md updateWithString:theString];
|
||||
return [md finalHash];
|
||||
}
|
||||
+ (NSString *)fileHash:(NSString *)theFile usingAlgorithm:(NSString *)theAlgorithm {
|
||||
MGMMD *md = [self mdWithAlgorithm:theAlgorithm];
|
||||
[md updateWithFile:theFile];
|
||||
return [md finalHash];
|
||||
}
|
||||
+ (NSString *)dataHash:(NSData *)theData usingAlgorithm:(NSString *)theAlgorithm {
|
||||
MGMMD *md = [self mdWithAlgorithm:theAlgorithm];
|
||||
[md updateWithData:theData];
|
||||
return [md finalHash];
|
||||
}
|
||||
|
||||
+ (NSArray *)supportedAlgorithms {
|
||||
NSMutableArray *algorithms = [NSMutableArray array];
|
||||
#ifdef _MD_MD5
|
||||
[algorithms addObject:MDNMD5];
|
||||
#endif
|
||||
#ifdef _MD_SHA1
|
||||
[algorithms addObject:MDNSHA1];
|
||||
#endif
|
||||
#ifdef _MD_SHA224
|
||||
[algorithms addObject:MDNSHA224];
|
||||
#endif
|
||||
#ifdef _MD_SHA256
|
||||
[algorithms addObject:MDNSHA256];
|
||||
#endif
|
||||
#ifdef _MD_SHA384
|
||||
[algorithms addObject:MDNSHA384];
|
||||
#endif
|
||||
#ifdef _MD_SHA512
|
||||
[algorithms addObject:MDNSHA512];
|
||||
#endif
|
||||
return algorithms;
|
||||
}
|
||||
|
||||
+ (id)mdWithAlgorithm:(NSString *)theAlgorithm {
|
||||
return [[self alloc] initWithAlgorithm:theAlgorithm];
|
||||
}
|
||||
- (id)initWithAlgorithm:(NSString *)theAlgorithm {
|
||||
if (self = [super init]) {
|
||||
theAlgorithm = [theAlgorithm lowercaseString];
|
||||
algorithm = MDNULL;
|
||||
context = NULL;
|
||||
#ifdef _MD_MD5
|
||||
if ([theAlgorithm isEqual:MDNMD5]) {
|
||||
algorithm = MDMD5;
|
||||
context = malloc(sizeof(struct MD5Context));
|
||||
MD5Init(context);
|
||||
algorithmLength = MD5Length;
|
||||
}
|
||||
#endif
|
||||
#ifdef _MD_SHA1
|
||||
if ([theAlgorithm isEqual:MDNSHA1]) {
|
||||
algorithm = MDSHA1;
|
||||
context = malloc(sizeof(struct SHA1Context));
|
||||
SHA1Init(context);
|
||||
algorithmLength = SHA1Length;
|
||||
}
|
||||
#endif
|
||||
#ifdef _MD_SHA224
|
||||
if ([theAlgorithm isEqual:MDNSHA224]) {
|
||||
algorithm = MDSHA224;
|
||||
context = malloc(sizeof(struct SHA224Context));
|
||||
SHA224Init(context);
|
||||
algorithmLength = SHA224Length;
|
||||
}
|
||||
#endif
|
||||
#ifdef _MD_SHA256
|
||||
if ([theAlgorithm isEqual:MDNSHA256]) {
|
||||
algorithm = MDSHA256;
|
||||
context = malloc(sizeof(struct SHA256Context));
|
||||
SHA256Init(context);
|
||||
algorithmLength = SHA256Length;
|
||||
}
|
||||
#endif
|
||||
#ifdef _MD_SHA384
|
||||
if ([theAlgorithm isEqual:MDNSHA384]) {
|
||||
algorithm = MDSHA384;
|
||||
context = malloc(sizeof(struct SHA384Context));
|
||||
SHA384Init(context);
|
||||
algorithmLength = SHA384Length;
|
||||
}
|
||||
#endif
|
||||
#ifdef _MD_SHA512
|
||||
if ([theAlgorithm isEqual:MDNSHA512]) {
|
||||
algorithm = MDSHA512;
|
||||
context = malloc(sizeof(struct SHA512Context));
|
||||
SHA512Init(context);
|
||||
algorithmLength = SHA512Length;
|
||||
}
|
||||
#endif
|
||||
if (algorithm==MDNULL) {
|
||||
NSLog(@"The alorithm \"%@\" is not supported.", theAlgorithm);
|
||||
[self release];
|
||||
self = nil;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc {
|
||||
if (context!=NULL)
|
||||
free(context);
|
||||
if (finalData!=nil)
|
||||
[finalData release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)updateWithString:(NSString *)theString {
|
||||
return [self updateWithData:[theString dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
}
|
||||
- (BOOL)updateWithFile:(NSString *)theFile {
|
||||
if (finalData!=nil) return NO;
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:theFile];
|
||||
if (file==nil)
|
||||
return NO;
|
||||
int length;
|
||||
do {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSData *MDData = [file readDataOfLength:MDFileReadLength];
|
||||
length = [MDData length];
|
||||
[self updateWithData:MDData];
|
||||
[pool release];
|
||||
} while (length>0);
|
||||
return YES;
|
||||
}
|
||||
- (BOOL)updateWithData:(NSData *)theData {
|
||||
return [self updateWithBytes:[theData bytes] length:[theData length]];
|
||||
}
|
||||
- (BOOL)updateWithBytes:(const char *)theBytes length:(int)theLength {
|
||||
if (finalData!=nil) return NO;
|
||||
#ifdef _MD_MD5
|
||||
if (algorithm==MDMD5)
|
||||
MD5Update(context, (const unsigned char *)theBytes, theLength);
|
||||
#endif
|
||||
#ifdef _MD_SHA1
|
||||
if (algorithm==MDSHA1)
|
||||
SHA1Update(context, (const unsigned char *)theBytes, theLength);
|
||||
#endif
|
||||
#ifdef _MD_SHA224
|
||||
if (algorithm==MDSHA224)
|
||||
SHA224Update(context, (const unsigned char *)theBytes, theLength);
|
||||
#endif
|
||||
#ifdef _MD_SHA256
|
||||
if (algorithm==MDSHA256)
|
||||
SHA256Update(context, (const unsigned char *)theBytes, theLength);
|
||||
#endif
|
||||
#ifdef _MD_SHA384
|
||||
if (algorithm==MDSHA384)
|
||||
SHA384Update(context, (const unsigned char *)theBytes, theLength);
|
||||
#endif
|
||||
#ifdef _MD_SHA512
|
||||
if (algorithm==MDSHA512)
|
||||
SHA512Update(context, (const unsigned char *)theBytes, theLength);
|
||||
#endif
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSData *)finalData {
|
||||
if (finalData==nil) {
|
||||
unsigned char MDDigest[algorithmLength];
|
||||
#ifdef _MD_MD5
|
||||
if (algorithm==MDMD5)
|
||||
MD5Final(MDDigest, context);
|
||||
#endif
|
||||
#ifdef _MD_SHA1
|
||||
if (algorithm==MDSHA1)
|
||||
SHA1Final(MDDigest, context);
|
||||
#endif
|
||||
#ifdef _MD_SHA224
|
||||
if (algorithm==MDSHA224)
|
||||
SHA224Final(MDDigest, context);
|
||||
#endif
|
||||
#ifdef _MD_SHA256
|
||||
if (algorithm==MDSHA256)
|
||||
SHA256Final(MDDigest, context);
|
||||
#endif
|
||||
#ifdef _MD_SHA384
|
||||
if (algorithm==MDSHA384)
|
||||
SHA384Final(MDDigest, context);
|
||||
#endif
|
||||
#ifdef _MD_SHA512
|
||||
if (algorithm==MDSHA512)
|
||||
SHA512Final(MDDigest, context);
|
||||
#endif
|
||||
finalData = [[NSData dataWithBytes:MDDigest length:algorithmLength] retain];
|
||||
}
|
||||
return finalData;
|
||||
}
|
||||
- (const char *)finalBytes {
|
||||
return [[self finalData] bytes];
|
||||
}
|
||||
- (const char *)finalStringHash {
|
||||
const size_t length = [[self finalData] length];
|
||||
const char *bytes = [[self finalData] bytes];
|
||||
char *stringBuffer = (char *)malloc(length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<length; i++) {
|
||||
*hexBuffer++ = hexdigits[(*bytes >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[*bytes & 0xF];
|
||||
bytes++;
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
return [[NSData dataWithBytesNoCopy:stringBuffer length:algorithmLength*2] bytes];
|
||||
}
|
||||
- (NSString *)finalHash {
|
||||
return [NSString stringWithUTF8String:[self finalStringHash]];
|
||||
}
|
||||
@end
|
48
Classes/MGMMD5.h
Normal file
48
Classes/MGMMD5.h
Normal file
@ -0,0 +1,48 @@
|
||||
//
|
||||
// MGMMD5.h
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 1/6/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#ifndef _MD_MD5
|
||||
#define _MD_MD5
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
extern NSString * const MDNMD5;
|
||||
|
||||
@interface NSString (MGMMD5)
|
||||
- (NSString *)MD5;
|
||||
- (NSString *)pathMD5;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *MD5String(const char *string, int length);
|
||||
char *MD5File(const char *path);
|
||||
|
||||
#define MD5Length 16
|
||||
#define MD5BufferSize 4
|
||||
|
||||
struct MD5Context {
|
||||
uint32_t buf[MD5BufferSize];
|
||||
uint32_t bits[2];
|
||||
unsigned char in[64];
|
||||
};
|
||||
|
||||
void MD5Init(struct MD5Context *context);
|
||||
void MD5Update(struct MD5Context *context, const unsigned char *buf, unsigned len);
|
||||
void MD5Final(unsigned char digest[MD5Length], struct MD5Context *context);
|
||||
void MD5Transform(uint32_t buf[MD5BufferSize], const unsigned char inraw[64]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
297
Classes/MGMMD5.m
Normal file
297
Classes/MGMMD5.m
Normal file
@ -0,0 +1,297 @@
|
||||
//
|
||||
// MGMMD5.m
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 1/6/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
// C Algorithm created by Colin Plumb
|
||||
//
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import "MGMMD5.h"
|
||||
#import "MGMMDTypes.h"
|
||||
|
||||
|
||||
NSString * const MDNMD5 = @"md5";
|
||||
|
||||
@implementation NSString (MGMMD5)
|
||||
- (NSString *)MD5 {
|
||||
NSData *MDData = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||
struct MD5Context MDContext;
|
||||
unsigned char MDDigest[MD5Length];
|
||||
|
||||
MD5Init(&MDContext);
|
||||
MD5Update(&MDContext, [MDData bytes], [MDData length]);
|
||||
MD5Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(MD5Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<MD5Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
- (NSString *)pathMD5 {
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:self];
|
||||
if (file==nil)
|
||||
return nil;
|
||||
struct MD5Context MDContext;
|
||||
unsigned char MDDigest[MD5Length];
|
||||
|
||||
MD5Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSData *MDData = [file readDataOfLength:MDFileReadLength];
|
||||
length = [MDData length];
|
||||
MD5Update(&MDContext, [MDData bytes], length);
|
||||
[pool release];
|
||||
} while (length>0);
|
||||
MD5Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(MD5Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<MD5Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "MGMMD5.h"
|
||||
#include "MGMMDTypes.h"
|
||||
#endif
|
||||
|
||||
char *MD5String(const char *string, int length) {
|
||||
struct MD5Context MDContext;
|
||||
unsigned char MDDigest[MD5Length];
|
||||
|
||||
MD5Init(&MDContext);
|
||||
MD5Update(&MDContext, (const unsigned char *)string, length);
|
||||
MD5Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(MD5Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<MD5Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
char *MD5File(const char *path) {
|
||||
FILE *file = fopen(path, "r");
|
||||
if (file==NULL)
|
||||
return NULL;
|
||||
struct MD5Context MDContext;
|
||||
unsigned char MDDigest[MD5Length];
|
||||
|
||||
MD5Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
unsigned char MDData[MDFileReadLength];
|
||||
length = fread(&MDData, 1, MDFileReadLength, file);
|
||||
MD5Update(&MDContext, MDData, length);
|
||||
} while (length>0);
|
||||
MD5Final(MDDigest, &MDContext);
|
||||
|
||||
fclose(file);
|
||||
|
||||
char *stringBuffer = (char *)malloc(MD5Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<MD5Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
void MD5Init(struct MD5Context *context) {
|
||||
context->buf[0] = 0x67452301;
|
||||
context->buf[1] = 0xefcdab89;
|
||||
context->buf[2] = 0x98badcfe;
|
||||
context->buf[3] = 0x10325476;
|
||||
|
||||
context->bits[0] = 0;
|
||||
context->bits[1] = 0;
|
||||
}
|
||||
|
||||
void MD5Update(struct MD5Context *context, const unsigned char *buf, unsigned len) {
|
||||
uint32_t t;
|
||||
|
||||
t = context->bits[0];
|
||||
if ((context->bits[0] = (t + ((uint32_t)len << 3))) < t)
|
||||
context->bits[1]++;
|
||||
context->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f;
|
||||
|
||||
if (t!=0) {
|
||||
unsigned char *p = context->in + t;
|
||||
|
||||
t = 64-t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
MD5Transform(context->buf, context->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
|
||||
while (len >= 64) {
|
||||
memcpy(context->in, buf, 64);
|
||||
MD5Transform(context->buf, context->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
memcpy(context->in, buf, len);
|
||||
}
|
||||
|
||||
void MD5Final(unsigned char digest[MD5Length], struct MD5Context *context) {
|
||||
unsigned count;
|
||||
unsigned char *p;
|
||||
|
||||
count = (context->bits[0] >> 3) & 0x3F;
|
||||
|
||||
p = context->in + count;
|
||||
*p++ = MDPadding[0];
|
||||
|
||||
count = 64 - 1 - count;
|
||||
|
||||
if (count < 8) {
|
||||
memset(p, MDPadding[1], count);
|
||||
MD5Transform(context->buf, context->in);
|
||||
|
||||
memset(context->in, MDPadding[1], 56);
|
||||
} else {
|
||||
memset(p, MDPadding[1], count-8);
|
||||
}
|
||||
|
||||
putu32l(context->bits[0], context->in + 56);
|
||||
putu32l(context->bits[1], context->in + 60);
|
||||
|
||||
MD5Transform(context->buf, context->in);
|
||||
for (int i=0; i<4; i++)
|
||||
putu32l(context->buf[i], digest + (4 * i));
|
||||
|
||||
memset(context, 0, sizeof(context));
|
||||
}
|
||||
|
||||
/* #define MD5_F1(x, y, z) (x & y | ~x & z) */
|
||||
#define MD5_F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define MD5_F2(x, y, z) MD5_F1(z, x, y)
|
||||
#define MD5_F3(x, y, z) (x ^ y ^ z)
|
||||
#define MD5_F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
#define MD5STEP(f, w, x, y, z, data, s) \
|
||||
( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
|
||||
|
||||
void MD5Transform(uint32_t buf[MD5BufferSize], const unsigned char inraw[64]) {
|
||||
uint32_t in[16];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; ++i) {
|
||||
in[i] = getu32l(inraw+4*i);
|
||||
}
|
||||
|
||||
uint32_t a = buf[0];
|
||||
uint32_t b = buf[1];
|
||||
uint32_t c = buf[2];
|
||||
uint32_t d = buf[3];
|
||||
|
||||
// Round 1
|
||||
MD5STEP(MD5_F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
|
||||
MD5STEP(MD5_F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
|
||||
MD5STEP(MD5_F1, c, d, a, b, in[ 2]+0x242070db, 17);
|
||||
MD5STEP(MD5_F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
|
||||
MD5STEP(MD5_F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
|
||||
MD5STEP(MD5_F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
|
||||
MD5STEP(MD5_F1, c, d, a, b, in[ 6]+0xa8304613, 17);
|
||||
MD5STEP(MD5_F1, b, c, d, a, in[ 7]+0xfd469501, 22);
|
||||
MD5STEP(MD5_F1, a, b, c, d, in[ 8]+0x698098d8, 7);
|
||||
MD5STEP(MD5_F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
|
||||
MD5STEP(MD5_F1, c, d, a, b, in[10]+0xffff5bb1, 17);
|
||||
MD5STEP(MD5_F1, b, c, d, a, in[11]+0x895cd7be, 22);
|
||||
MD5STEP(MD5_F1, a, b, c, d, in[12]+0x6b901122, 7);
|
||||
MD5STEP(MD5_F1, d, a, b, c, in[13]+0xfd987193, 12);
|
||||
MD5STEP(MD5_F1, c, d, a, b, in[14]+0xa679438e, 17);
|
||||
MD5STEP(MD5_F1, b, c, d, a, in[15]+0x49b40821, 22);
|
||||
|
||||
// Round 2
|
||||
MD5STEP(MD5_F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
|
||||
MD5STEP(MD5_F2, d, a, b, c, in[ 6]+0xc040b340, 9);
|
||||
MD5STEP(MD5_F2, c, d, a, b, in[11]+0x265e5a51, 14);
|
||||
MD5STEP(MD5_F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
|
||||
MD5STEP(MD5_F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
|
||||
MD5STEP(MD5_F2, d, a, b, c, in[10]+0x02441453, 9);
|
||||
MD5STEP(MD5_F2, c, d, a, b, in[15]+0xd8a1e681, 14);
|
||||
MD5STEP(MD5_F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
|
||||
MD5STEP(MD5_F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
|
||||
MD5STEP(MD5_F2, d, a, b, c, in[14]+0xc33707d6, 9);
|
||||
MD5STEP(MD5_F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
|
||||
MD5STEP(MD5_F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
|
||||
MD5STEP(MD5_F2, a, b, c, d, in[13]+0xa9e3e905, 5);
|
||||
MD5STEP(MD5_F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
|
||||
MD5STEP(MD5_F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
|
||||
MD5STEP(MD5_F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
|
||||
|
||||
// Round 3
|
||||
MD5STEP(MD5_F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
|
||||
MD5STEP(MD5_F3, d, a, b, c, in[ 8]+0x8771f681, 11);
|
||||
MD5STEP(MD5_F3, c, d, a, b, in[11]+0x6d9d6122, 16);
|
||||
MD5STEP(MD5_F3, b, c, d, a, in[14]+0xfde5380c, 23);
|
||||
MD5STEP(MD5_F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
|
||||
MD5STEP(MD5_F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
|
||||
MD5STEP(MD5_F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
|
||||
MD5STEP(MD5_F3, b, c, d, a, in[10]+0xbebfbc70, 23);
|
||||
MD5STEP(MD5_F3, a, b, c, d, in[13]+0x289b7ec6, 4);
|
||||
MD5STEP(MD5_F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
|
||||
MD5STEP(MD5_F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
|
||||
MD5STEP(MD5_F3, b, c, d, a, in[ 6]+0x04881d05, 23);
|
||||
MD5STEP(MD5_F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
|
||||
MD5STEP(MD5_F3, d, a, b, c, in[12]+0xe6db99e5, 11);
|
||||
MD5STEP(MD5_F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
|
||||
MD5STEP(MD5_F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
|
||||
|
||||
// Round 4
|
||||
MD5STEP(MD5_F4, a, b, c, d, in[ 0]+0xf4292244, 6);
|
||||
MD5STEP(MD5_F4, d, a, b, c, in[ 7]+0x432aff97, 10);
|
||||
MD5STEP(MD5_F4, c, d, a, b, in[14]+0xab9423a7, 15);
|
||||
MD5STEP(MD5_F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
|
||||
MD5STEP(MD5_F4, a, b, c, d, in[12]+0x655b59c3, 6);
|
||||
MD5STEP(MD5_F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
|
||||
MD5STEP(MD5_F4, c, d, a, b, in[10]+0xffeff47d, 15);
|
||||
MD5STEP(MD5_F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
|
||||
MD5STEP(MD5_F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
|
||||
MD5STEP(MD5_F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
|
||||
MD5STEP(MD5_F4, c, d, a, b, in[ 6]+0xa3014314, 15);
|
||||
MD5STEP(MD5_F4, b, c, d, a, in[13]+0x4e0811a1, 21);
|
||||
MD5STEP(MD5_F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
|
||||
MD5STEP(MD5_F4, d, a, b, c, in[11]+0xbd3af235, 10);
|
||||
MD5STEP(MD5_F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
|
||||
MD5STEP(MD5_F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
100
Classes/MGMMDTypes.h
Normal file
100
Classes/MGMMDTypes.h
Normal file
@ -0,0 +1,100 @@
|
||||
//
|
||||
// MGMMDTypes.h
|
||||
//
|
||||
// Created by Mr. Gecko on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#define INT64(n) n ## ULL
|
||||
|
||||
#define ROR32(x, b) ((x >> b) | (x << (32 - b)))
|
||||
#define ROR64(x, b) ((x >> b) | (x << (64 - b)))
|
||||
#define SHR(x, b) (x >> b)
|
||||
|
||||
#define MDFileReadLength 1048576
|
||||
|
||||
static const char hexdigits[] = "0123456789abcdef";
|
||||
|
||||
static const unsigned char MDPadding[128] =
|
||||
{
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static uint32_t getu32(const uint8_t *addr) {
|
||||
return ((uint32_t)addr[0] << 24)
|
||||
| ((uint32_t)addr[1] << 16)
|
||||
| ((uint32_t)addr[2] << 8)
|
||||
| ((uint32_t)addr[3]);
|
||||
}
|
||||
static void putu32(uint32_t data, uint8_t *addr) {
|
||||
addr[0] = (uint8_t)(data >> 24);
|
||||
addr[1] = (uint8_t)(data >> 16);
|
||||
addr[2] = (uint8_t)(data >> 8);
|
||||
addr[3] = (uint8_t)data;
|
||||
}
|
||||
|
||||
static uint64_t getu64(const uint8_t *addr) {
|
||||
return ((uint64_t)addr[0] << 56)
|
||||
| ((uint64_t)addr[1] << 48)
|
||||
| ((uint64_t)addr[2] << 40)
|
||||
| ((uint64_t)addr[3] << 32)
|
||||
| ((uint64_t)addr[4] << 24)
|
||||
| ((uint64_t)addr[5] << 16)
|
||||
| ((uint64_t)addr[6] << 8)
|
||||
| ((uint64_t)addr[7]);
|
||||
}
|
||||
static void putu64(uint64_t data, uint8_t *addr) {
|
||||
addr[0] = (uint8_t)(data >> 56);
|
||||
addr[1] = (uint8_t)(data >> 48);
|
||||
addr[2] = (uint8_t)(data >> 40);
|
||||
addr[3] = (uint8_t)(data >> 32);
|
||||
addr[4] = (uint8_t)(data >> 24);
|
||||
addr[5] = (uint8_t)(data >> 16);
|
||||
addr[6] = (uint8_t)(data >> 8);
|
||||
addr[7] = (uint8_t)data;
|
||||
}
|
||||
|
||||
static uint32_t getu32l(const uint8_t *addr) {
|
||||
return ((uint32_t)addr[0])
|
||||
| ((uint32_t)addr[1] << 8)
|
||||
| ((uint32_t)addr[2] << 16)
|
||||
| ((uint32_t)addr[3] << 24);
|
||||
}
|
||||
static void putu32l(uint32_t data, uint8_t *addr) {
|
||||
addr[0] = (uint8_t)data;
|
||||
addr[1] = (uint8_t)(data >> 8);
|
||||
addr[2] = (uint8_t)(data >> 16);
|
||||
addr[3] = (uint8_t)(data >> 24);
|
||||
}
|
||||
|
||||
static uint64_t getu64l(const uint8_t *addr) {
|
||||
return ((uint64_t)addr[0])
|
||||
| ((uint64_t)addr[1] << 8)
|
||||
| ((uint64_t)addr[2] << 16)
|
||||
| ((uint64_t)addr[3] << 24)
|
||||
| ((uint64_t)addr[4] << 32)
|
||||
| ((uint64_t)addr[5] << 40)
|
||||
| ((uint64_t)addr[6] << 48)
|
||||
| ((uint64_t)addr[7] << 56);
|
||||
}
|
||||
static void putu64l(uint64_t data, uint8_t *addr) {
|
||||
addr[0] = (uint8_t)data;
|
||||
addr[1] = (uint8_t)(data >> 8);
|
||||
addr[2] = (uint8_t)(data >> 16);
|
||||
addr[3] = (uint8_t)(data >> 24);
|
||||
addr[4] = (uint8_t)(data >> 32);
|
||||
addr[5] = (uint8_t)(data >> 40);
|
||||
addr[6] = (uint8_t)(data >> 48);
|
||||
addr[7] = (uint8_t)(data >> 56);
|
||||
}
|
48
Classes/MGMSHA1.h
Normal file
48
Classes/MGMSHA1.h
Normal file
@ -0,0 +1,48 @@
|
||||
//
|
||||
// MGMSHA1.h
|
||||
// MGMMD
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 8/23/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#ifndef _MD_SHA1
|
||||
#define _MD_SHA1
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString * const MDNSHA1;
|
||||
|
||||
@interface NSString (MGMSHA1)
|
||||
- (NSString *)SHA1;
|
||||
- (NSString *)pathSHA1;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *SHA1String(const char *string, int length);
|
||||
char *SHA1File(const char *path);
|
||||
|
||||
#define SHA1Length 20
|
||||
#define SHA1BufferSize 5
|
||||
|
||||
struct SHA1Context {
|
||||
uint32_t buf[SHA1BufferSize];
|
||||
uint32_t bits[2];
|
||||
unsigned char in[64];
|
||||
};
|
||||
|
||||
void SHA1Init(struct SHA1Context *context);
|
||||
void SHA1Update(struct SHA1Context *context, const unsigned char *buf, unsigned len);
|
||||
void SHA1Final(unsigned char digest[SHA1Length], struct SHA1Context *context);
|
||||
void SHA1Transform(uint32_t buf[SHA1BufferSize], const unsigned char inraw[64]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
225
Classes/MGMSHA1.m
Normal file
225
Classes/MGMSHA1.m
Normal file
@ -0,0 +1,225 @@
|
||||
//
|
||||
// MGMSHA1.m
|
||||
// MGMMD
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 8/23/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
// C Algorithm created by Steve Reid <steve@edmweb.com>
|
||||
//
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import "MGMSHA1.h"
|
||||
#import "MGMMDTypes.h"
|
||||
|
||||
NSString * const MDNSHA1 = @"sha1";
|
||||
|
||||
@implementation NSString (MGMSHA1)
|
||||
- (NSString *)SHA1 {
|
||||
NSData *MDData = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||
struct SHA1Context MDContext;
|
||||
unsigned char MDDigest[SHA1Length];
|
||||
|
||||
SHA1Init(&MDContext);
|
||||
SHA1Update(&MDContext, [MDData bytes], [MDData length]);
|
||||
SHA1Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA1Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA1Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
- (NSString *)pathSHA1 {
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:self];
|
||||
if (file==nil)
|
||||
return nil;
|
||||
struct SHA1Context MDContext;
|
||||
unsigned char MDDigest[SHA1Length];
|
||||
|
||||
SHA1Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSData *MDData = [file readDataOfLength:MDFileReadLength];
|
||||
length = [MDData length];
|
||||
SHA1Update(&MDContext, [MDData bytes], length);
|
||||
[pool release];
|
||||
} while (length>0);
|
||||
SHA1Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA1Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA1Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "MGMMD5.h"
|
||||
#include "MGMMDTypes.h"
|
||||
#endif
|
||||
|
||||
char *SHA1String(const char *string, int length) {
|
||||
struct SHA1Context MDContext;
|
||||
unsigned char MDDigest[SHA1Length];
|
||||
|
||||
SHA1Init(&MDContext);
|
||||
SHA1Update(&MDContext, (const unsigned char *)string, length);
|
||||
SHA1Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA1Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA1Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
char *SHA1File(const char *path) {
|
||||
FILE *file = fopen(path, "r");
|
||||
if (file==NULL)
|
||||
return NULL;
|
||||
struct SHA1Context MDContext;
|
||||
unsigned char MDDigest[SHA1Length];
|
||||
|
||||
SHA1Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
unsigned char MDData[MDFileReadLength];
|
||||
length = fread(&MDData, 1, MDFileReadLength, file);
|
||||
SHA1Update(&MDContext, MDData, length);
|
||||
} while (length>0);
|
||||
SHA1Final(MDDigest, &MDContext);
|
||||
|
||||
fclose(file);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA1Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA1Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
void SHA1Init(struct SHA1Context *context) {
|
||||
context->buf[0] = 0x67452301;
|
||||
context->buf[1] = 0xEFCDAB89;
|
||||
context->buf[2] = 0x98BADCFE;
|
||||
context->buf[3] = 0x10325476;
|
||||
context->buf[4] = 0xC3D2E1F0;
|
||||
|
||||
context->bits[0] = 0;
|
||||
context->bits[1] = 0;
|
||||
}
|
||||
|
||||
void SHA1Update(struct SHA1Context *context, const unsigned char *buf, unsigned len) {
|
||||
u_int32_t i, j;
|
||||
|
||||
j = context->bits[0];
|
||||
if ((context->bits[0] += len << 3) < j)
|
||||
context->bits[1]++;
|
||||
context->bits[1] += (len>>29);
|
||||
j = (j >> 3) & 63;
|
||||
if ((j + len) > 63) {
|
||||
memcpy(&context->in[j], buf, (i = 64-j));
|
||||
SHA1Transform(context->buf, context->in);
|
||||
for ( ; i + 63 < len; i += 64) {
|
||||
SHA1Transform(context->buf, &buf[i]);
|
||||
}
|
||||
j = 0;
|
||||
}
|
||||
else i = 0;
|
||||
memcpy(&context->in[j], &buf[i], len - i);
|
||||
}
|
||||
|
||||
void SHA1Final(unsigned char digest[SHA1Length], struct SHA1Context *context) {
|
||||
unsigned char bits[8];
|
||||
unsigned int count;
|
||||
|
||||
putu32(context->bits[1], bits);
|
||||
putu32(context->bits[0], bits + 4);
|
||||
|
||||
count = (context->bits[0] >> 3) & 0x3f;
|
||||
count = (count < 56) ? (56 - count) : (120 - count);
|
||||
SHA1Update(context, MDPadding, count);
|
||||
|
||||
SHA1Update(context, bits, 8);
|
||||
|
||||
for (int i=0; i<5; i++)
|
||||
putu32(context->buf[i], digest + (4 * i));
|
||||
|
||||
memset(context, 0, sizeof(context));
|
||||
}
|
||||
|
||||
#define SHA1_rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define SHA1_blk0(i) (block->l[i] = (SHA1_rol(block->l[i], 24)&0xFF00FF00) |(SHA1_rol(block->l[i], 8)&0x00FF00FF))
|
||||
#elif BYTE_ORDER == BIG_ENDIAN
|
||||
#define SHA1_blk0(i) block->l[i]
|
||||
#else
|
||||
#error "Endianness not defined!"
|
||||
#endif
|
||||
#define SHA1_blk(i) (block->l[i&15] = SHA1_rol(block->l[(i+13)&15]^block->l[(i+8)&15] ^block->l[(i+2)&15]^block->l[i&15], 1))
|
||||
|
||||
#define SHA1_R0(v, w, x, y, z, i) z+=((w&(x^y))^y)+SHA1_blk0(i)+0x5A827999+SHA1_rol(v, 5);w=SHA1_rol(w, 30);
|
||||
#define SHA1_R1(v, w, x, y, z, i) z+=((w&(x^y))^y)+SHA1_blk(i)+0x5A827999+SHA1_rol(v, 5);w=SHA1_rol(w, 30);
|
||||
#define SHA1_R2(v, w, x, y, z, i) z+=(w^x^y)+SHA1_blk(i)+0x6ED9EBA1+SHA1_rol(v, 5);w=SHA1_rol(w, 30);
|
||||
#define SHA1_R3(v, w, x, y, z, i) z+=(((w|x)&y)|(w&x))+SHA1_blk(i)+0x8F1BBCDC+SHA1_rol(v, 5);w=SHA1_rol(w, 30);
|
||||
#define SHA1_R4(v, w, x, y, z, i) z+=(w^x^y)+SHA1_blk(i)+0xCA62C1D6+SHA1_rol(v, 5);w=SHA1_rol(w, 30);
|
||||
|
||||
#define SHA1STEP(v, w, x, y, z, i) \
|
||||
if (i<16) {SHA1_R0(v, w, x, y, z, i);} else \
|
||||
if (i<20) {SHA1_R1(v, w, x, y, z, i);} else \
|
||||
if (i<40) {SHA1_R2(v, w, x, y, z, i);} else \
|
||||
if (i<60) {SHA1_R3(v, w, x, y, z, i);} else \
|
||||
if (i<80) {SHA1_R4(v, w, x, y, z, i);}
|
||||
|
||||
void SHA1Transform(uint32_t buf[SHA1BufferSize], const unsigned char inraw[64]) {
|
||||
typedef union {
|
||||
char c[64];
|
||||
u_int32_t l[16];
|
||||
} SHA1LONG;
|
||||
SHA1LONG *block = (SHA1LONG *)inraw;
|
||||
|
||||
u_int32_t a = buf[0];
|
||||
u_int32_t b = buf[1];
|
||||
u_int32_t c = buf[2];
|
||||
u_int32_t d = buf[3];
|
||||
u_int32_t e = buf[4];
|
||||
|
||||
for (int i=0; i<79; i = i+5) {
|
||||
SHA1STEP(a, b, c, d, e, i);
|
||||
SHA1STEP(e, a, b, c, d, i + 1);
|
||||
SHA1STEP(d, e, a, b, c, i + 2);
|
||||
SHA1STEP(c, d, e, a, b, i + 3);
|
||||
SHA1STEP(b, c, d, e, a, i + 4);
|
||||
}
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
buf[4] += e;
|
||||
}
|
47
Classes/MGMSHA224.h
Normal file
47
Classes/MGMSHA224.h
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// MGMSHA224.h
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#ifndef _MD_SHA224
|
||||
#define _MD_SHA224
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString * const MDNSHA224;
|
||||
|
||||
@interface NSString (MGMSHA224)
|
||||
- (NSString *)SHA224;
|
||||
- (NSString *)pathSHA224;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *SHA224String(const char *string, int length);
|
||||
char *SHA224File(const char *path);
|
||||
|
||||
#define SHA224Length 28
|
||||
#define SHA224BufferSize 8
|
||||
|
||||
struct SHA224Context {
|
||||
uint32_t buf[SHA224BufferSize];
|
||||
uint32_t bits[2];
|
||||
unsigned char in[64];
|
||||
};
|
||||
|
||||
void SHA224Init(struct SHA224Context *context);
|
||||
void SHA224Update(struct SHA224Context *context, const unsigned char *buf, unsigned int len);
|
||||
void SHA224Final(unsigned char digest[SHA224Length], struct SHA224Context *context);
|
||||
void SHA224Transform(uint32_t buf[SHA224BufferSize], const unsigned char inraw[64]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
258
Classes/MGMSHA224.m
Normal file
258
Classes/MGMSHA224.m
Normal file
@ -0,0 +1,258 @@
|
||||
//
|
||||
// MGMSHA224.m
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
// C Algorithm created by Tom St Denis <tomstdenis@gmail.com> <http://libtom.org>
|
||||
//
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import "MGMSHA224.h"
|
||||
#import "MGMMDTypes.h"
|
||||
|
||||
NSString * const MDNSHA224 = @"sha224";
|
||||
|
||||
@implementation NSString (MGMSHA224)
|
||||
- (NSString *)SHA224 {
|
||||
NSData *MDData = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||
struct SHA224Context MDContext;
|
||||
unsigned char MDDigest[SHA224Length];
|
||||
|
||||
SHA224Init(&MDContext);
|
||||
SHA224Update(&MDContext, [MDData bytes], [MDData length]);
|
||||
SHA224Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA224Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA224Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
- (NSString *)pathSHA224 {
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:self];
|
||||
if (file==nil)
|
||||
return nil;
|
||||
struct SHA224Context MDContext;
|
||||
unsigned char MDDigest[SHA224Length];
|
||||
|
||||
SHA224Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSData *MDData = [file readDataOfLength:MDFileReadLength];
|
||||
length = [MDData length];
|
||||
SHA224Update(&MDContext, [MDData bytes], length);
|
||||
[pool release];
|
||||
} while (length>0);
|
||||
SHA224Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA224Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA224Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "MGMMD5.h"
|
||||
#include "MGMMDTypes.h"
|
||||
#endif
|
||||
|
||||
char *SHA224String(const char *string, int length) {
|
||||
struct SHA224Context MDContext;
|
||||
unsigned char MDDigest[SHA224Length];
|
||||
|
||||
SHA224Init(&MDContext);
|
||||
SHA224Update(&MDContext, (const unsigned char *)string, length);
|
||||
SHA224Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA224Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA224Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
char *SHA224File(const char *path) {
|
||||
FILE *file = fopen(path, "r");
|
||||
if (file==NULL)
|
||||
return NULL;
|
||||
struct SHA224Context MDContext;
|
||||
unsigned char MDDigest[SHA224Length];
|
||||
|
||||
SHA224Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
unsigned char MDData[MDFileReadLength];
|
||||
length = fread(&MDData, 1, MDFileReadLength, file);
|
||||
SHA224Update(&MDContext, MDData, length);
|
||||
} while (length>0);
|
||||
SHA224Final(MDDigest, &MDContext);
|
||||
|
||||
fclose(file);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA224Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA224Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
void SHA224Init(struct SHA224Context *context) {
|
||||
context->buf[0] = 0xc1059ed8;
|
||||
context->buf[1] = 0x367cd507;
|
||||
context->buf[2] = 0x3070dd17;
|
||||
context->buf[3] = 0xf70e5939;
|
||||
context->buf[4] = 0xffc00b31;
|
||||
context->buf[5] = 0x68581511;
|
||||
context->buf[6] = 0x64f98fa7;
|
||||
context->buf[7] = 0xbefa4fa4;
|
||||
|
||||
context->bits[0] = 0;
|
||||
context->bits[1] = 0;
|
||||
}
|
||||
|
||||
void SHA224Update(struct SHA224Context *context, const unsigned char *buf, unsigned int len) {
|
||||
uint32_t t;
|
||||
|
||||
t = context->bits[0];
|
||||
if ((context->bits[0] = (t + ((uint32_t)len << 3))) < t)
|
||||
context->bits[1]++;
|
||||
context->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f;
|
||||
|
||||
if (t!=0) {
|
||||
unsigned char *p = context->in + t;
|
||||
|
||||
t = 64-t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
SHA224Transform(context->buf, context->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
|
||||
while (len >= 64) {
|
||||
memcpy(context->in, buf, 64);
|
||||
SHA224Transform(context->buf, context->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
memcpy(context->in, buf, len);
|
||||
}
|
||||
|
||||
void SHA224Final(unsigned char digest[SHA224Length], struct SHA224Context *context) {
|
||||
unsigned char bits[8];
|
||||
unsigned int count;
|
||||
|
||||
putu32(context->bits[1], bits);
|
||||
putu32(context->bits[0], bits + 4);
|
||||
|
||||
count = (context->bits[0] >> 3) & 0x3f;
|
||||
count = (count < 56) ? (56 - count) : (120 - count);
|
||||
SHA224Update(context, MDPadding, count);
|
||||
|
||||
SHA224Update(context, bits, 8);
|
||||
|
||||
for (int i=0; i<7; i++)
|
||||
putu32(context->buf[i], digest + (4 * i));
|
||||
|
||||
memset(context, 0, sizeof(context));
|
||||
}
|
||||
|
||||
/* #define SHA224_F1(x, y, z) (x & y | ~x & z) */
|
||||
#define SHA224_F1(x,y,z) (z ^ (x & (y ^ z)))
|
||||
#define SHA224_F2(x,y,z) (((x | y) & z) | (x & y))
|
||||
// SUM0
|
||||
#define SHA224_F3(x) (ROR32(x, 2) ^ ROR32(x, 13) ^ ROR32(x, 22))
|
||||
// SUM1
|
||||
#define SHA224_F4(x) (ROR32(x, 6) ^ ROR32(x, 11) ^ ROR32(x, 25))
|
||||
// OM0
|
||||
#define SHA224_F5(x) (ROR32(x, 7) ^ ROR32(x, 18) ^ SHR(x, 3))
|
||||
// OM1
|
||||
#define SHA224_F6(x) (ROR32(x, 17) ^ ROR32(x, 19) ^ SHR(x, 10))
|
||||
|
||||
static const uint32_t SHA224_Key[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
#define SHA224STEP(a, b, c, d, e, f, g, h, s) \
|
||||
t1 = h + SHA224_F4(e) + SHA224_F1(e, f, g) + SHA224_Key[s] + in[s]; \
|
||||
t2 = SHA224_F3(a) + SHA224_F2(a, b, c); \
|
||||
d += t1; \
|
||||
h = t1 + t2;
|
||||
|
||||
void SHA224Transform(uint32_t buf[SHA224BufferSize], const unsigned char inraw[64]) {
|
||||
uint32_t in[64], t1, t2;
|
||||
int i;
|
||||
|
||||
uint32_t a = buf[0];
|
||||
uint32_t b = buf[1];
|
||||
uint32_t c = buf[2];
|
||||
uint32_t d = buf[3];
|
||||
uint32_t e = buf[4];
|
||||
uint32_t f = buf[5];
|
||||
uint32_t g = buf[6];
|
||||
uint32_t h = buf[7];
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
in[i] = getu32(inraw+4*i);
|
||||
|
||||
for (i = 16; i < 64; i++)
|
||||
in[i] = SHA224_F6(in[i - 2]) + in[i - 7] + SHA224_F5(in[i - 15]) + in[i - 16];
|
||||
|
||||
for (int i=0; i<64; i = i+8) {
|
||||
SHA224STEP(a, b, c, d, e, f, g, h, i);
|
||||
SHA224STEP(h, a, b, c, d, e, f, g, i + 1);
|
||||
SHA224STEP(g, h, a, b, c, d, e, f, i + 2);
|
||||
SHA224STEP(f, g, h, a, b, c, d, e, i + 3);
|
||||
SHA224STEP(e, f, g, h, a, b, c, d, i + 4);
|
||||
SHA224STEP(d, e, f, g, h, a, b, c, i + 5);
|
||||
SHA224STEP(c, d, e, f, g, h, a, b, i + 6);
|
||||
SHA224STEP(b, c, d, e, f, g, h, a, i + 7);
|
||||
}
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
buf[4] += e;
|
||||
buf[5] += f;
|
||||
buf[6] += g;
|
||||
buf[7] += h;
|
||||
}
|
47
Classes/MGMSHA256.h
Normal file
47
Classes/MGMSHA256.h
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// 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
|
||||
|
||||
char *SHA256String(const char *string, int length);
|
||||
char *SHA256File(const char *path);
|
||||
|
||||
#define SHA256Length 32
|
||||
#define SHA256BufferSize 8
|
||||
|
||||
struct SHA256Context {
|
||||
uint32_t buf[SHA256BufferSize];
|
||||
uint32_t bits[2];
|
||||
unsigned char in[64];
|
||||
};
|
||||
|
||||
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);
|
||||
void SHA256Transform(uint32_t buf[SHA256BufferSize], const unsigned char inraw[64]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
258
Classes/MGMSHA256.m
Normal file
258
Classes/MGMSHA256.m
Normal file
@ -0,0 +1,258 @@
|
||||
//
|
||||
// MGMSHA256.m
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
// C Algorithm created by Tom St Denis <tomstdenis@gmail.com> <http://libtom.org>
|
||||
//
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import "MGMSHA256.h"
|
||||
#import "MGMMDTypes.h"
|
||||
|
||||
NSString * const MDNSHA256 = @"sha256";
|
||||
|
||||
@implementation NSString (MGMSHA256)
|
||||
- (NSString *)SHA256 {
|
||||
NSData *MDData = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||
struct SHA256Context MDContext;
|
||||
unsigned char MDDigest[SHA256Length];
|
||||
|
||||
SHA256Init(&MDContext);
|
||||
SHA256Update(&MDContext, [MDData bytes], [MDData length]);
|
||||
SHA256Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA256Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA256Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
- (NSString *)pathSHA256 {
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:self];
|
||||
if (file==nil)
|
||||
return nil;
|
||||
struct SHA256Context MDContext;
|
||||
unsigned char MDDigest[SHA256Length];
|
||||
|
||||
SHA256Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSData *MDData = [file readDataOfLength:MDFileReadLength];
|
||||
length = [MDData length];
|
||||
SHA256Update(&MDContext, [MDData bytes], length);
|
||||
[pool release];
|
||||
} while (length>0);
|
||||
SHA256Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA256Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA256Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "MGMMD5.h"
|
||||
#include "MGMMDTypes.h"
|
||||
#endif
|
||||
|
||||
char *SHA256String(const char *string, int length) {
|
||||
struct SHA256Context MDContext;
|
||||
unsigned char MDDigest[SHA256Length];
|
||||
|
||||
SHA256Init(&MDContext);
|
||||
SHA256Update(&MDContext, (const unsigned char *)string, length);
|
||||
SHA256Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA256Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA256Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
char *SHA256File(const char *path) {
|
||||
FILE *file = fopen(path, "r");
|
||||
if (file==NULL)
|
||||
return NULL;
|
||||
struct SHA256Context MDContext;
|
||||
unsigned char MDDigest[SHA256Length];
|
||||
|
||||
SHA256Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
unsigned char MDData[MDFileReadLength];
|
||||
length = fread(&MDData, 1, MDFileReadLength, file);
|
||||
SHA256Update(&MDContext, MDData, length);
|
||||
} while (length>0);
|
||||
SHA256Final(MDDigest, &MDContext);
|
||||
|
||||
fclose(file);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA256Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA256Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
void SHA256Init(struct SHA256Context *context) {
|
||||
context->buf[0] = 0x6a09e667;
|
||||
context->buf[1] = 0xbb67ae85;
|
||||
context->buf[2] = 0x3c6ef372;
|
||||
context->buf[3] = 0xa54ff53a;
|
||||
context->buf[4] = 0x510e527f;
|
||||
context->buf[5] = 0x9b05688c;
|
||||
context->buf[6] = 0x1f83d9ab;
|
||||
context->buf[7] = 0x5be0cd19;
|
||||
|
||||
context->bits[0] = 0;
|
||||
context->bits[1] = 0;
|
||||
}
|
||||
|
||||
void SHA256Update(struct SHA256Context *context, const unsigned char *buf, unsigned int len) {
|
||||
uint32_t t;
|
||||
|
||||
t = context->bits[0];
|
||||
if ((context->bits[0] = (t + ((uint32_t)len << 3))) < t)
|
||||
context->bits[1]++;
|
||||
context->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f;
|
||||
|
||||
if (t!=0) {
|
||||
unsigned char *p = context->in + t;
|
||||
|
||||
t = 64-t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
SHA256Transform(context->buf, context->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
|
||||
while (len >= 64) {
|
||||
memcpy(context->in, buf, 64);
|
||||
SHA256Transform(context->buf, context->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
memcpy(context->in, buf, len);
|
||||
}
|
||||
|
||||
void SHA256Final(unsigned char digest[SHA256Length], struct SHA256Context *context) {
|
||||
unsigned char bits[8];
|
||||
unsigned int count;
|
||||
|
||||
putu32(context->bits[1], bits);
|
||||
putu32(context->bits[0], bits + 4);
|
||||
|
||||
count = (context->bits[0] >> 3) & 0x3f;
|
||||
count = (count < 56) ? (56 - count) : (120 - count);
|
||||
SHA256Update(context, MDPadding, count);
|
||||
|
||||
SHA256Update(context, bits, 8);
|
||||
|
||||
for (int i=0; i<8; i++)
|
||||
putu32(context->buf[i], digest + (4 * i));
|
||||
|
||||
memset(context, 0, sizeof(context));
|
||||
}
|
||||
|
||||
/* #define SHA256_F1(x, y, z) (x & y | ~x & z) */
|
||||
#define SHA256_F1(x,y,z) (z ^ (x & (y ^ z)))
|
||||
#define SHA256_F2(x,y,z) (((x | y) & z) | (x & y))
|
||||
// SUM0
|
||||
#define SHA256_F3(x) (ROR32(x, 2) ^ ROR32(x, 13) ^ ROR32(x, 22))
|
||||
// SUM1
|
||||
#define SHA256_F4(x) (ROR32(x, 6) ^ ROR32(x, 11) ^ ROR32(x, 25))
|
||||
// OM0
|
||||
#define SHA256_F5(x) (ROR32(x, 7) ^ ROR32(x, 18) ^ SHR(x, 3))
|
||||
// OM1
|
||||
#define SHA256_F6(x) (ROR32(x, 17) ^ ROR32(x, 19) ^ SHR(x, 10))
|
||||
|
||||
static const uint32_t SHA256_Key[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
#define SHA256STEP(a, b, c, d, e, f, g, h, s) \
|
||||
t1 = h + SHA256_F4(e) + SHA256_F1(e, f, g) + SHA256_Key[s] + in[s]; \
|
||||
t2 = SHA256_F3(a) + SHA256_F2(a, b, c); \
|
||||
d += t1; \
|
||||
h = t1 + t2;
|
||||
|
||||
void SHA256Transform(uint32_t buf[SHA256BufferSize], const unsigned char inraw[64]) {
|
||||
uint32_t in[64], t1, t2;
|
||||
int i;
|
||||
|
||||
uint32_t a = buf[0];
|
||||
uint32_t b = buf[1];
|
||||
uint32_t c = buf[2];
|
||||
uint32_t d = buf[3];
|
||||
uint32_t e = buf[4];
|
||||
uint32_t f = buf[5];
|
||||
uint32_t g = buf[6];
|
||||
uint32_t h = buf[7];
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
in[i] = getu32(inraw+4*i);
|
||||
|
||||
for (i = 16; i < 64; i++)
|
||||
in[i] = SHA256_F6(in[i - 2]) + in[i - 7] + SHA256_F5(in[i - 15]) + in[i - 16];
|
||||
|
||||
for (int i=0; i<64; i = i + 8) {
|
||||
SHA256STEP(a, b, c, d, e, f, g, h, i);
|
||||
SHA256STEP(h, a, b, c, d, e, f, g, i + 1);
|
||||
SHA256STEP(g, h, a, b, c, d, e, f, i + 2);
|
||||
SHA256STEP(f, g, h, a, b, c, d, e, i + 3);
|
||||
SHA256STEP(e, f, g, h, a, b, c, d, i + 4);
|
||||
SHA256STEP(d, e, f, g, h, a, b, c, i + 5);
|
||||
SHA256STEP(c, d, e, f, g, h, a, b, i + 6);
|
||||
SHA256STEP(b, c, d, e, f, g, h, a, i + 7);
|
||||
}
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
buf[4] += e;
|
||||
buf[5] += f;
|
||||
buf[6] += g;
|
||||
buf[7] += h;
|
||||
}
|
47
Classes/MGMSHA384.h
Normal file
47
Classes/MGMSHA384.h
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// MGMSHA384.h
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#ifndef _MD_SHA384
|
||||
#define _MD_SHA384
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString * const MDNSHA384;
|
||||
|
||||
@interface NSString (MGMSHA384)
|
||||
- (NSString *)SHA384;
|
||||
- (NSString *)pathSHA384;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *SHA384String(const char *string, int length);
|
||||
char *SHA384File(const char *path);
|
||||
|
||||
#define SHA384Length 48
|
||||
#define SHA384BufferSize 8
|
||||
|
||||
struct SHA384Context {
|
||||
uint64_t buf[SHA384BufferSize];
|
||||
uint64_t bits[2];
|
||||
unsigned char in[128];
|
||||
};
|
||||
|
||||
void SHA384Init(struct SHA384Context *context);
|
||||
void SHA384Update(struct SHA384Context *context, const unsigned char *buf, uint64_t len);
|
||||
void SHA384Final(unsigned char digest[SHA384Length], struct SHA384Context *context);
|
||||
void SHA384Transform(uint64_t buf[SHA384BufferSize], const unsigned char inraw[80]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
270
Classes/MGMSHA384.m
Normal file
270
Classes/MGMSHA384.m
Normal file
@ -0,0 +1,270 @@
|
||||
//
|
||||
// MGMSHA384.m
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
// C Algorithm created by Tom St Denis <tomstdenis@gmail.com> <http://libtom.org>
|
||||
//
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import "MGMSHA384.h"
|
||||
#import "MGMMDTypes.h"
|
||||
|
||||
NSString * const MDNSHA384 = @"sha384";
|
||||
|
||||
@implementation NSString (MGMSHA384)
|
||||
- (NSString *)SHA384 {
|
||||
NSData *MDData = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||
struct SHA384Context MDContext;
|
||||
unsigned char MDDigest[SHA384Length];
|
||||
|
||||
SHA384Init(&MDContext);
|
||||
SHA384Update(&MDContext, [MDData bytes], [MDData length]);
|
||||
SHA384Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA384Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA384Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
- (NSString *)pathSHA384 {
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:self];
|
||||
if (file==nil)
|
||||
return nil;
|
||||
struct SHA384Context MDContext;
|
||||
unsigned char MDDigest[SHA384Length];
|
||||
|
||||
SHA384Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSData *MDData = [file readDataOfLength:MDFileReadLength];
|
||||
length = [MDData length];
|
||||
SHA384Update(&MDContext, [MDData bytes], length);
|
||||
[pool release];
|
||||
} while (length>0);
|
||||
SHA384Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA384Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA384Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "MGMMD5.h"
|
||||
#include "MGMMDTypes.h"
|
||||
#endif
|
||||
|
||||
char *SHA384String(const char *string, int length) {
|
||||
struct SHA384Context MDContext;
|
||||
unsigned char MDDigest[SHA384Length];
|
||||
|
||||
SHA384Init(&MDContext);
|
||||
SHA384Update(&MDContext, (const unsigned char *)string, length);
|
||||
SHA384Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA384Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA384Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
char *SHA384File(const char *path) {
|
||||
FILE *file = fopen(path, "r");
|
||||
if (file==NULL)
|
||||
return NULL;
|
||||
struct SHA384Context MDContext;
|
||||
unsigned char MDDigest[SHA384Length];
|
||||
|
||||
SHA384Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
unsigned char MDData[MDFileReadLength];
|
||||
length = fread(&MDData, 1, MDFileReadLength, file);
|
||||
SHA384Update(&MDContext, MDData, length);
|
||||
} while (length>0);
|
||||
SHA384Final(MDDigest, &MDContext);
|
||||
|
||||
fclose(file);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA384Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA384Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
void SHA384Init(struct SHA384Context *context) {
|
||||
context->buf[0] = INT64(0xcbbb9d5dc1059ed8);
|
||||
context->buf[1] = INT64(0x629a292a367cd507);
|
||||
context->buf[2] = INT64(0x9159015a3070dd17);
|
||||
context->buf[3] = INT64(0x152fecd8f70e5939);
|
||||
context->buf[4] = INT64(0x67332667ffc00b31);
|
||||
context->buf[5] = INT64(0x8eb44a8768581511);
|
||||
context->buf[6] = INT64(0xdb0c2e0d64f98fa7);
|
||||
context->buf[7] = INT64(0x47b5481dbefa4fa4);
|
||||
|
||||
context->bits[0] = 0;
|
||||
context->bits[1] = 0;
|
||||
}
|
||||
|
||||
void SHA384Update(struct SHA384Context *context, const unsigned char *buf, uint64_t len) {
|
||||
uint64_t t;
|
||||
|
||||
t = context->bits[0];
|
||||
if ((context->bits[0] = (t + ((uint64_t)len << 3))) < t)
|
||||
context->bits[1]++;
|
||||
context->bits[1] += len >> 61;
|
||||
|
||||
t = (t >> 3) & 0x7f;
|
||||
|
||||
if (t!=0) {
|
||||
unsigned char *p = context->in + t;
|
||||
|
||||
t = 128-t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
SHA384Transform(context->buf, context->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
|
||||
while (len >= 128) {
|
||||
memcpy(context->in, buf, 128);
|
||||
SHA384Transform(context->buf, context->in);
|
||||
buf += 128;
|
||||
len -= 128;
|
||||
}
|
||||
|
||||
memcpy(context->in, buf, len);
|
||||
}
|
||||
|
||||
void SHA384Final(unsigned char digest[SHA384Length], struct SHA384Context *context) {
|
||||
unsigned char bits[16];
|
||||
unsigned int count;
|
||||
|
||||
putu64(context->bits[1], bits);
|
||||
putu64(context->bits[0], bits + 8);
|
||||
|
||||
count = (context->bits[0] >> 3) & 0x7f;
|
||||
count = (count < 112) ? (112 - count) : (240 - count);
|
||||
SHA384Update(context, MDPadding, count);
|
||||
|
||||
SHA384Update(context, bits, 16);
|
||||
|
||||
for (int i=0; i<6; i++)
|
||||
putu64(context->buf[i], digest + (8 * i));
|
||||
|
||||
memset(context, 0, sizeof(context));
|
||||
}
|
||||
|
||||
/* #define SHA384_F1(x, y, z) (x & y | ~x & z) */
|
||||
#define SHA384_F1(x,y,z) (z ^ (x & (y ^ z)))
|
||||
#define SHA384_F2(x,y,z) (((x | y) & z) | (x & y))
|
||||
// SUM0
|
||||
#define SHA384_F3(x) (ROR64(x, 28) ^ ROR64(x, 34) ^ ROR64(x, 39))
|
||||
// SUM1
|
||||
#define SHA384_F4(x) (ROR64(x, 14) ^ ROR64(x, 18) ^ ROR64(x, 41))
|
||||
// OM0
|
||||
#define SHA384_F5(x) (ROR64(x, 1) ^ ROR64(x, 8) ^ SHR(x, 7))
|
||||
// OM1
|
||||
#define SHA384_F6(x) (ROR64(x, 19) ^ ROR64(x, 61) ^ SHR(x, 6))
|
||||
|
||||
static const uint64_t SHA384_Key[128] = {
|
||||
INT64(0x428a2f98d728ae22), INT64(0x7137449123ef65cd), INT64(0xb5c0fbcfec4d3b2f), INT64(0xe9b5dba58189dbbc),
|
||||
INT64(0x3956c25bf348b538), INT64(0x59f111f1b605d019), INT64(0x923f82a4af194f9b), INT64(0xab1c5ed5da6d8118),
|
||||
INT64(0xd807aa98a3030242), INT64(0x12835b0145706fbe), INT64(0x243185be4ee4b28c), INT64(0x550c7dc3d5ffb4e2),
|
||||
INT64(0x72be5d74f27b896f), INT64(0x80deb1fe3b1696b1), INT64(0x9bdc06a725c71235), INT64(0xc19bf174cf692694),
|
||||
INT64(0xe49b69c19ef14ad2), INT64(0xefbe4786384f25e3), INT64(0x0fc19dc68b8cd5b5), INT64(0x240ca1cc77ac9c65),
|
||||
INT64(0x2de92c6f592b0275), INT64(0x4a7484aa6ea6e483), INT64(0x5cb0a9dcbd41fbd4), INT64(0x76f988da831153b5),
|
||||
INT64(0x983e5152ee66dfab), INT64(0xa831c66d2db43210), INT64(0xb00327c898fb213f), INT64(0xbf597fc7beef0ee4),
|
||||
INT64(0xc6e00bf33da88fc2), INT64(0xd5a79147930aa725), INT64(0x06ca6351e003826f), INT64(0x142929670a0e6e70),
|
||||
INT64(0x27b70a8546d22ffc), INT64(0x2e1b21385c26c926), INT64(0x4d2c6dfc5ac42aed), INT64(0x53380d139d95b3df),
|
||||
INT64(0x650a73548baf63de), INT64(0x766a0abb3c77b2a8), INT64(0x81c2c92e47edaee6), INT64(0x92722c851482353b),
|
||||
INT64(0xa2bfe8a14cf10364), INT64(0xa81a664bbc423001), INT64(0xc24b8b70d0f89791), INT64(0xc76c51a30654be30),
|
||||
INT64(0xd192e819d6ef5218), INT64(0xd69906245565a910), INT64(0xf40e35855771202a), INT64(0x106aa07032bbd1b8),
|
||||
INT64(0x19a4c116b8d2d0c8), INT64(0x1e376c085141ab53), INT64(0x2748774cdf8eeb99), INT64(0x34b0bcb5e19b48a8),
|
||||
INT64(0x391c0cb3c5c95a63), INT64(0x4ed8aa4ae3418acb), INT64(0x5b9cca4f7763e373), INT64(0x682e6ff3d6b2b8a3),
|
||||
INT64(0x748f82ee5defb2fc), INT64(0x78a5636f43172f60), INT64(0x84c87814a1f0ab72), INT64(0x8cc702081a6439ec),
|
||||
INT64(0x90befffa23631e28), INT64(0xa4506cebde82bde9), INT64(0xbef9a3f7b2c67915), INT64(0xc67178f2e372532b),
|
||||
INT64(0xca273eceea26619c), INT64(0xd186b8c721c0c207), INT64(0xeada7dd6cde0eb1e), INT64(0xf57d4f7fee6ed178),
|
||||
INT64(0x06f067aa72176fba), INT64(0x0a637dc5a2c898a6), INT64(0x113f9804bef90dae), INT64(0x1b710b35131c471b),
|
||||
INT64(0x28db77f523047d84), INT64(0x32caab7b40c72493), INT64(0x3c9ebe0a15c9bebc), INT64(0x431d67c49c100d4c),
|
||||
INT64(0x4cc5d4becb3e42b6), INT64(0x597f299cfc657e2a), INT64(0x5fcb6fab3ad6faec), INT64(0x6c44198c4a475817)
|
||||
};
|
||||
|
||||
#define SHA384STEP(a, b, c, d, e, f, g, h, s) \
|
||||
t1 = h + SHA384_F4(e) + SHA384_F1(e, f, g) + SHA384_Key[s] + in[s]; \
|
||||
t2 = SHA384_F3(a) + SHA384_F2(a, b, c); \
|
||||
d += t1; \
|
||||
h = t1 + t2;
|
||||
|
||||
void SHA384Transform(uint64_t buf[SHA384BufferSize], const unsigned char inraw[80]) {
|
||||
uint64_t in[80], t1, t2;
|
||||
int i;
|
||||
|
||||
uint64_t a = buf[0];
|
||||
uint64_t b = buf[1];
|
||||
uint64_t c = buf[2];
|
||||
uint64_t d = buf[3];
|
||||
uint64_t e = buf[4];
|
||||
uint64_t f = buf[5];
|
||||
uint64_t g = buf[6];
|
||||
uint64_t h = buf[7];
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
in[i] = getu64(inraw+8*i);
|
||||
|
||||
for (i = 16; i < 80; i++)
|
||||
in[i] = SHA384_F6(in[i - 2]) + in[i - 7] + SHA384_F5(in[i - 15]) + in[i - 16];
|
||||
|
||||
for (int i=0; i<80; i = i + 8) {
|
||||
SHA384STEP(a, b, c, d, e, f, g, h, i);
|
||||
SHA384STEP(h, a, b, c, d, e, f, g, i + 1);
|
||||
SHA384STEP(g, h, a, b, c, d, e, f, i + 2);
|
||||
SHA384STEP(f, g, h, a, b, c, d, e, i + 3);
|
||||
SHA384STEP(e, f, g, h, a, b, c, d, i + 4);
|
||||
SHA384STEP(d, e, f, g, h, a, b, c, i + 5);
|
||||
SHA384STEP(c, d, e, f, g, h, a, b, i + 6);
|
||||
SHA384STEP(b, c, d, e, f, g, h, a, i + 7);
|
||||
}
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
buf[4] += e;
|
||||
buf[5] += f;
|
||||
buf[6] += g;
|
||||
buf[7] += h;
|
||||
}
|
47
Classes/MGMSHA512.h
Normal file
47
Classes/MGMSHA512.h
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// MGMSHA512.h
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#ifndef _MD_SHA512
|
||||
#define _MD_SHA512
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString * const MDNSHA512;
|
||||
|
||||
@interface NSString (MGMSHA512)
|
||||
- (NSString *)SHA512;
|
||||
- (NSString *)pathSHA512;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *SHA512String(const char *string, int length);
|
||||
char *SHA512File(const char *path);
|
||||
|
||||
#define SHA512Length 64
|
||||
#define SHA512BufferSize 8
|
||||
|
||||
struct SHA512Context {
|
||||
uint64_t buf[SHA512BufferSize];
|
||||
uint64_t bits[2];
|
||||
unsigned char in[128];
|
||||
};
|
||||
|
||||
void SHA512Init(struct SHA512Context *context);
|
||||
void SHA512Update(struct SHA512Context *context, const unsigned char *buf, uint64_t len);
|
||||
void SHA512Final(unsigned char digest[SHA512Length], struct SHA512Context *context);
|
||||
void SHA512Transform(uint64_t buf[SHA512BufferSize], const unsigned char inraw[80]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
270
Classes/MGMSHA512.m
Normal file
270
Classes/MGMSHA512.m
Normal file
@ -0,0 +1,270 @@
|
||||
//
|
||||
// MGMSHA512.m
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/24/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
// C Algorithm created by Tom St Denis <tomstdenis@gmail.com> <http://libtom.org>
|
||||
//
|
||||
|
||||
#ifdef __NEXT_RUNTIME__
|
||||
#import "MGMSHA512.h"
|
||||
#import "MGMMDTypes.h"
|
||||
|
||||
NSString * const MDNSHA512 = @"sha512";
|
||||
|
||||
@implementation NSString (MGMSHA512)
|
||||
- (NSString *)SHA512 {
|
||||
NSData *MDData = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||
struct SHA512Context MDContext;
|
||||
unsigned char MDDigest[SHA512Length];
|
||||
|
||||
SHA512Init(&MDContext);
|
||||
SHA512Update(&MDContext, [MDData bytes], [MDData length]);
|
||||
SHA512Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA512Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA512Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
- (NSString *)pathSHA512 {
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:self];
|
||||
if (file==nil)
|
||||
return nil;
|
||||
struct SHA512Context MDContext;
|
||||
unsigned char MDDigest[SHA512Length];
|
||||
|
||||
SHA512Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSData *MDData = [file readDataOfLength:MDFileReadLength];
|
||||
length = [MDData length];
|
||||
SHA512Update(&MDContext, [MDData bytes], length);
|
||||
[pool release];
|
||||
} while (length>0);
|
||||
SHA512Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA512Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA512Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
NSString *hash = [NSString stringWithUTF8String:stringBuffer];
|
||||
free(stringBuffer);
|
||||
return hash;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "MGMMD5.h"
|
||||
#include "MGMMDTypes.h"
|
||||
#endif
|
||||
|
||||
char *SHA512String(const char *string, int length) {
|
||||
struct SHA512Context MDContext;
|
||||
unsigned char MDDigest[SHA512Length];
|
||||
|
||||
SHA512Init(&MDContext);
|
||||
SHA512Update(&MDContext, (const unsigned char *)string, length);
|
||||
SHA512Final(MDDigest, &MDContext);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA512Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA512Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
char *SHA512File(const char *path) {
|
||||
FILE *file = fopen(path, "r");
|
||||
if (file==NULL)
|
||||
return NULL;
|
||||
struct SHA512Context MDContext;
|
||||
unsigned char MDDigest[SHA512Length];
|
||||
|
||||
SHA512Init(&MDContext);
|
||||
int length;
|
||||
do {
|
||||
unsigned char MDData[MDFileReadLength];
|
||||
length = fread(&MDData, 1, MDFileReadLength, file);
|
||||
SHA512Update(&MDContext, MDData, length);
|
||||
} while (length>0);
|
||||
SHA512Final(MDDigest, &MDContext);
|
||||
|
||||
fclose(file);
|
||||
|
||||
char *stringBuffer = (char *)malloc(SHA512Length * 2 + 1);
|
||||
char *hexBuffer = stringBuffer;
|
||||
|
||||
for (int i=0; i<SHA512Length; i++) {
|
||||
*hexBuffer++ = hexdigits[(MDDigest[i] >> 4) & 0xF];
|
||||
*hexBuffer++ = hexdigits[MDDigest[i] & 0xF];
|
||||
}
|
||||
*hexBuffer = '\0';
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
void SHA512Init(struct SHA512Context *context) {
|
||||
context->buf[0] = INT64(0x6a09e667f3bcc908);
|
||||
context->buf[1] = INT64(0xbb67ae8584caa73b);
|
||||
context->buf[2] = INT64(0x3c6ef372fe94f82b);
|
||||
context->buf[3] = INT64(0xa54ff53a5f1d36f1);
|
||||
context->buf[4] = INT64(0x510e527fade682d1);
|
||||
context->buf[5] = INT64(0x9b05688c2b3e6c1f);
|
||||
context->buf[6] = INT64(0x1f83d9abfb41bd6b);
|
||||
context->buf[7] = INT64(0x5be0cd19137e2179);
|
||||
|
||||
context->bits[0] = 0;
|
||||
context->bits[1] = 0;
|
||||
}
|
||||
|
||||
void SHA512Update(struct SHA512Context *context, const unsigned char *buf, uint64_t len) {
|
||||
uint64_t t;
|
||||
|
||||
t = context->bits[0];
|
||||
if ((context->bits[0] = (t + ((uint64_t)len << 3))) < t)
|
||||
context->bits[1]++;
|
||||
context->bits[1] += len >> 61;
|
||||
|
||||
t = (t >> 3) & 0x7f;
|
||||
|
||||
if (t!=0) {
|
||||
unsigned char *p = context->in + t;
|
||||
|
||||
t = 128-t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
SHA512Transform(context->buf, context->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
|
||||
while (len >= 128) {
|
||||
memcpy(context->in, buf, 128);
|
||||
SHA512Transform(context->buf, context->in);
|
||||
buf += 128;
|
||||
len -= 128;
|
||||
}
|
||||
|
||||
memcpy(context->in, buf, len);
|
||||
}
|
||||
|
||||
void SHA512Final(unsigned char digest[SHA512Length], struct SHA512Context *context) {
|
||||
unsigned char bits[16];
|
||||
unsigned int count;
|
||||
|
||||
putu64(context->bits[1], bits);
|
||||
putu64(context->bits[0], bits + 8);
|
||||
|
||||
count = (context->bits[0] >> 3) & 0x7f;
|
||||
count = (count < 112) ? (112 - count) : (240 - count);
|
||||
SHA512Update(context, MDPadding, count);
|
||||
|
||||
SHA512Update(context, bits, 16);
|
||||
|
||||
for (int i=0; i<8; i++)
|
||||
putu64(context->buf[i], digest + (8 * i));
|
||||
|
||||
memset(context, 0, sizeof(context));
|
||||
}
|
||||
|
||||
/* #define SHA512_F1(x, y, z) (x & y | ~x & z) */
|
||||
#define SHA512_F1(x,y,z) (z ^ (x & (y ^ z)))
|
||||
#define SHA512_F2(x,y,z) (((x | y) & z) | (x & y))
|
||||
// SUM0
|
||||
#define SHA512_F3(x) (ROR64(x, 28) ^ ROR64(x, 34) ^ ROR64(x, 39))
|
||||
// SUM1
|
||||
#define SHA512_F4(x) (ROR64(x, 14) ^ ROR64(x, 18) ^ ROR64(x, 41))
|
||||
// OM0
|
||||
#define SHA512_F5(x) (ROR64(x, 1) ^ ROR64(x, 8) ^ SHR(x, 7))
|
||||
// OM1
|
||||
#define SHA512_F6(x) (ROR64(x, 19) ^ ROR64(x, 61) ^ SHR(x, 6))
|
||||
|
||||
static const uint64_t SHA512_Key[128] = {
|
||||
INT64(0x428a2f98d728ae22), INT64(0x7137449123ef65cd), INT64(0xb5c0fbcfec4d3b2f), INT64(0xe9b5dba58189dbbc),
|
||||
INT64(0x3956c25bf348b538), INT64(0x59f111f1b605d019), INT64(0x923f82a4af194f9b), INT64(0xab1c5ed5da6d8118),
|
||||
INT64(0xd807aa98a3030242), INT64(0x12835b0145706fbe), INT64(0x243185be4ee4b28c), INT64(0x550c7dc3d5ffb4e2),
|
||||
INT64(0x72be5d74f27b896f), INT64(0x80deb1fe3b1696b1), INT64(0x9bdc06a725c71235), INT64(0xc19bf174cf692694),
|
||||
INT64(0xe49b69c19ef14ad2), INT64(0xefbe4786384f25e3), INT64(0x0fc19dc68b8cd5b5), INT64(0x240ca1cc77ac9c65),
|
||||
INT64(0x2de92c6f592b0275), INT64(0x4a7484aa6ea6e483), INT64(0x5cb0a9dcbd41fbd4), INT64(0x76f988da831153b5),
|
||||
INT64(0x983e5152ee66dfab), INT64(0xa831c66d2db43210), INT64(0xb00327c898fb213f), INT64(0xbf597fc7beef0ee4),
|
||||
INT64(0xc6e00bf33da88fc2), INT64(0xd5a79147930aa725), INT64(0x06ca6351e003826f), INT64(0x142929670a0e6e70),
|
||||
INT64(0x27b70a8546d22ffc), INT64(0x2e1b21385c26c926), INT64(0x4d2c6dfc5ac42aed), INT64(0x53380d139d95b3df),
|
||||
INT64(0x650a73548baf63de), INT64(0x766a0abb3c77b2a8), INT64(0x81c2c92e47edaee6), INT64(0x92722c851482353b),
|
||||
INT64(0xa2bfe8a14cf10364), INT64(0xa81a664bbc423001), INT64(0xc24b8b70d0f89791), INT64(0xc76c51a30654be30),
|
||||
INT64(0xd192e819d6ef5218), INT64(0xd69906245565a910), INT64(0xf40e35855771202a), INT64(0x106aa07032bbd1b8),
|
||||
INT64(0x19a4c116b8d2d0c8), INT64(0x1e376c085141ab53), INT64(0x2748774cdf8eeb99), INT64(0x34b0bcb5e19b48a8),
|
||||
INT64(0x391c0cb3c5c95a63), INT64(0x4ed8aa4ae3418acb), INT64(0x5b9cca4f7763e373), INT64(0x682e6ff3d6b2b8a3),
|
||||
INT64(0x748f82ee5defb2fc), INT64(0x78a5636f43172f60), INT64(0x84c87814a1f0ab72), INT64(0x8cc702081a6439ec),
|
||||
INT64(0x90befffa23631e28), INT64(0xa4506cebde82bde9), INT64(0xbef9a3f7b2c67915), INT64(0xc67178f2e372532b),
|
||||
INT64(0xca273eceea26619c), INT64(0xd186b8c721c0c207), INT64(0xeada7dd6cde0eb1e), INT64(0xf57d4f7fee6ed178),
|
||||
INT64(0x06f067aa72176fba), INT64(0x0a637dc5a2c898a6), INT64(0x113f9804bef90dae), INT64(0x1b710b35131c471b),
|
||||
INT64(0x28db77f523047d84), INT64(0x32caab7b40c72493), INT64(0x3c9ebe0a15c9bebc), INT64(0x431d67c49c100d4c),
|
||||
INT64(0x4cc5d4becb3e42b6), INT64(0x597f299cfc657e2a), INT64(0x5fcb6fab3ad6faec), INT64(0x6c44198c4a475817)
|
||||
};
|
||||
|
||||
#define SHA512STEP(a, b, c, d, e, f, g, h, s) \
|
||||
t1 = h + SHA512_F4(e) + SHA512_F1(e, f, g) + SHA512_Key[s] + in[s]; \
|
||||
t2 = SHA512_F3(a) + SHA512_F2(a, b, c); \
|
||||
d += t1; \
|
||||
h = t1 + t2;
|
||||
|
||||
void SHA512Transform(uint64_t buf[SHA512BufferSize], const unsigned char inraw[80]) {
|
||||
uint64_t in[80], t1, t2;
|
||||
int i;
|
||||
|
||||
uint64_t a = buf[0];
|
||||
uint64_t b = buf[1];
|
||||
uint64_t c = buf[2];
|
||||
uint64_t d = buf[3];
|
||||
uint64_t e = buf[4];
|
||||
uint64_t f = buf[5];
|
||||
uint64_t g = buf[6];
|
||||
uint64_t h = buf[7];
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
in[i] = getu64(inraw+8*i);
|
||||
|
||||
for (i = 16; i < 80; i++)
|
||||
in[i] = SHA512_F6(in[i - 2]) + in[i - 7] + SHA512_F5(in[i - 15]) + in[i - 16];
|
||||
|
||||
for (int i=0; i<80; i = i + 8) {
|
||||
SHA512STEP(a, b, c, d, e, f, g, h, i);
|
||||
SHA512STEP(h, a, b, c, d, e, f, g, i + 1);
|
||||
SHA512STEP(g, h, a, b, c, d, e, f, i + 2);
|
||||
SHA512STEP(f, g, h, a, b, c, d, e, i + 3);
|
||||
SHA512STEP(e, f, g, h, a, b, c, d, i + 4);
|
||||
SHA512STEP(d, e, f, g, h, a, b, c, i + 5);
|
||||
SHA512STEP(c, d, e, f, g, h, a, b, i + 6);
|
||||
SHA512STEP(b, c, d, e, f, g, h, a, i + 7);
|
||||
}
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
buf[4] += e;
|
||||
buf[5] += f;
|
||||
buf[6] += g;
|
||||
buf[7] += h;
|
||||
}
|
2
MDTest.bin
Executable file
2
MDTest.bin
Executable file
@ -0,0 +1,2 @@
|
||||
D ECPHEgR┤▓s┘Ь7G▐┐(Ь┐H'Ч▌┐▄█┐(x╗4)─E┤ы┐rHx≥ьxxx#xxxЬxxxxx┐&vzйЩzx,Щё#зы┤Хxzь≈ь td2x√]g╔juG8b8√ыzmx#vь├7╖nh(≈╖6xx⌠r┤зgCj²┐┴g2x┤┌x╗s┬в┐r8≈┴═c'Fb0t6W|╖з~зp!7⌠rвsx÷┴w
|
||||
x≈
╖}┴x▓x}┴z ┤╖┴в(≈┴}┴╖ы┼xs┤B┴╖ь≈8x }┴2x≈з┴s┴s)░╜┴╞╜┤8'┤╗√#xg├зxdxnrg█╜xjxmxg├xgc'├xgmx╕xж╗}jxcG┌g█╕x┐'┴в┴╖ь≈┤╜xз╘в┴┴xx≈┴}╗≈ь x²x≈┴x≈┴в┴x≈┴xы╖┴╖█x }┴╕wg█÷h oxgьjxg╕}gь╕в├ЩxФxgхg▌ГЬмЖxйВ▄╙╛╗xХ≈чc G4fV╔4&√vВ
|
79
MGMMD.1
Normal file
79
MGMMD.1
Normal file
@ -0,0 +1,79 @@
|
||||
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
|
||||
.\"See Also:
|
||||
.\"man mdoc.samples for a complete listing of options
|
||||
.\"man mdoc for the short list of editing options
|
||||
.\"/usr/share/misc/mdoc.template
|
||||
.Dd 8/23/10 \" DATE
|
||||
.Dt MGMMD 1 \" Program name and manual section number
|
||||
.Os Darwin
|
||||
.Sh NAME \" Section Header - required - don't modify
|
||||
.Nm MGMMD,
|
||||
.\" The following lines are read in generating the apropos(man -k) database. Use only key
|
||||
.\" words here as the database is built based on the words here and in the .ND line.
|
||||
.Nm Other_name_for_same_program(),
|
||||
.Nm Yet another name for the same program.
|
||||
.\" Use .Nm macro to designate other names for the documented program.
|
||||
.Nd This line parsed for whatis database.
|
||||
.Sh SYNOPSIS \" Section Header - required - don't modify
|
||||
.Nm
|
||||
.Op Fl abcd \" [-abcd]
|
||||
.Op Fl a Ar path \" [-a path]
|
||||
.Op Ar file \" [file]
|
||||
.Op Ar \" [file ...]
|
||||
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
|
||||
arg2 ... \" Arguments
|
||||
.Sh DESCRIPTION \" Section Header - required - don't modify
|
||||
Use the .Nm macro to refer to your program throughout the man page like such:
|
||||
.Nm
|
||||
Underlining is accomplished with the .Ar macro like this:
|
||||
.Ar underlined text .
|
||||
.Pp \" Inserts a space
|
||||
A list of items with descriptions:
|
||||
.Bl -tag -width -indent \" Begins a tagged list
|
||||
.It item a \" Each item preceded by .It macro
|
||||
Description of item a
|
||||
.It item b
|
||||
Description of item b
|
||||
.El \" Ends the list
|
||||
.Pp
|
||||
A list of flags and their descriptions:
|
||||
.Bl -tag -width -indent \" Differs from above in tag removed
|
||||
.It Fl a \"-a flag as a list item
|
||||
Description of -a flag
|
||||
.It Fl b
|
||||
Description of -b flag
|
||||
.El \" Ends the list
|
||||
.Pp
|
||||
.\" .Sh ENVIRONMENT \" May not be needed
|
||||
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
|
||||
.\" .It Ev ENV_VAR_1
|
||||
.\" Description of ENV_VAR_1
|
||||
.\" .It Ev ENV_VAR_2
|
||||
.\" Description of ENV_VAR_2
|
||||
.\" .El
|
||||
.Sh FILES \" File used or created by the topic of the man page
|
||||
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
|
||||
.It Pa /usr/share/file_name
|
||||
FILE_1 description
|
||||
.It Pa /Users/joeuser/Library/really_long_file_name
|
||||
FILE_2 description
|
||||
.El \" Ends the list
|
||||
.\" .Sh DIAGNOSTICS \" May not be needed
|
||||
.\" .Bl -diag
|
||||
.\" .It Diagnostic Tag
|
||||
.\" Diagnostic informtion here.
|
||||
.\" .It Diagnostic Tag
|
||||
.\" Diagnostic informtion here.
|
||||
.\" .El
|
||||
.Sh SEE ALSO
|
||||
.\" List links in ascending order by section, alphabetically within a section.
|
||||
.\" Please do not reference files that do not exist without filing a bug report
|
||||
.Xr a 1 ,
|
||||
.Xr b 1 ,
|
||||
.Xr c 1 ,
|
||||
.Xr a 2 ,
|
||||
.Xr b 2 ,
|
||||
.Xr a 3 ,
|
||||
.Xr b 3
|
||||
.\" .Sh BUGS \" Document known, unremedied bugs
|
||||
.\" .Sh HISTORY \" Document history if command behaves in a unique manner
|
812
MGMMD.xcodeproj/project.pbxproj
Normal file
812
MGMMD.xcodeproj/project.pbxproj
Normal file
@ -0,0 +1,812 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
2A2CBB1E1222A4F200C864D8 /* MGMMD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB141222A4F200C864D8 /* MGMMD5.m */; };
|
||||
2A2CBB1F1222A4F200C864D8 /* MGMSHA224.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB171222A4F200C864D8 /* MGMSHA224.m */; };
|
||||
2A2CBB201222A4F200C864D8 /* MGMSHA256.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB191222A4F200C864D8 /* MGMSHA256.m */; };
|
||||
2A2CBB211222A4F200C864D8 /* MGMSHA384.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1B1222A4F200C864D8 /* MGMSHA384.m */; };
|
||||
2A2CBB221222A4F200C864D8 /* MGMSHA512.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1D1222A4F200C864D8 /* MGMSHA512.m */; };
|
||||
2A2CBBD91222BC0600C864D8 /* MGMSHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBBD81222BC0600C864D8 /* MGMSHA1.m */; };
|
||||
2A91445412230D880075E219 /* MGMMD.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A91445312230D880075E219 /* MGMMD.m */; };
|
||||
2A9145F812233E1C0075E219 /* MGMMD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB141222A4F200C864D8 /* MGMMD5.m */; };
|
||||
2A9145F912233E1C0075E219 /* MGMSHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBBD81222BC0600C864D8 /* MGMSHA1.m */; };
|
||||
2A9145FA12233E1C0075E219 /* MGMSHA224.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB171222A4F200C864D8 /* MGMSHA224.m */; };
|
||||
2A9145FB12233E1C0075E219 /* MGMSHA256.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB191222A4F200C864D8 /* MGMSHA256.m */; };
|
||||
2A9145FC12233E1C0075E219 /* MGMSHA384.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1B1222A4F200C864D8 /* MGMSHA384.m */; };
|
||||
2A9145FD12233E1C0075E219 /* MGMSHA512.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1D1222A4F200C864D8 /* MGMSHA512.m */; };
|
||||
2A9145FE12233E1C0075E219 /* MGMMD.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A91445312230D880075E219 /* MGMMD.m */; };
|
||||
2A91460012233E450075E219 /* MGMMDTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB151222A4F200C864D8 /* MGMMDTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91460112233E450075E219 /* MGMMD5.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB131222A4F200C864D8 /* MGMMD5.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91460212233E450075E219 /* MGMSHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBBD71222BC0600C864D8 /* MGMSHA1.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91460312233E450075E219 /* MGMSHA224.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB161222A4F200C864D8 /* MGMSHA224.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91460412233E450075E219 /* MGMSHA256.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB181222A4F200C864D8 /* MGMSHA256.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91460512233E450075E219 /* MGMSHA384.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1A1222A4F200C864D8 /* MGMSHA384.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91460612233E450075E219 /* MGMSHA512.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1C1222A4F200C864D8 /* MGMSHA512.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91460712233E450075E219 /* MGMMD.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A91445212230D880075E219 /* MGMMD.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461412233F800075E219 /* MGMMDTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB151222A4F200C864D8 /* MGMMDTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461512233F800075E219 /* MGMMD5.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB131222A4F200C864D8 /* MGMMD5.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461612233F800075E219 /* MGMSHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBBD71222BC0600C864D8 /* MGMSHA1.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461712233F800075E219 /* MGMSHA224.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB161222A4F200C864D8 /* MGMSHA224.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461812233F800075E219 /* MGMSHA256.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB181222A4F200C864D8 /* MGMSHA256.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461912233F800075E219 /* MGMSHA384.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1A1222A4F200C864D8 /* MGMSHA384.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461A12233F800075E219 /* MGMSHA512.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1C1222A4F200C864D8 /* MGMSHA512.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461B12233F800075E219 /* MGMMD.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A91445212230D880075E219 /* MGMMD.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91461C12233F9E0075E219 /* MGMMD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB141222A4F200C864D8 /* MGMMD5.m */; };
|
||||
2A91461D12233F9E0075E219 /* MGMSHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBBD81222BC0600C864D8 /* MGMSHA1.m */; };
|
||||
2A91461E12233F9E0075E219 /* MGMSHA224.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB171222A4F200C864D8 /* MGMSHA224.m */; };
|
||||
2A91461F12233F9E0075E219 /* MGMSHA256.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB191222A4F200C864D8 /* MGMSHA256.m */; };
|
||||
2A91462012233F9E0075E219 /* MGMSHA384.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1B1222A4F200C864D8 /* MGMSHA384.m */; };
|
||||
2A91462112233F9E0075E219 /* MGMSHA512.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1D1222A4F200C864D8 /* MGMSHA512.m */; };
|
||||
2A91462212233F9E0075E219 /* MGMMD.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A91445312230D880075E219 /* MGMMD.m */; };
|
||||
2A91463B122340780075E219 /* MGMMDTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB151222A4F200C864D8 /* MGMMDTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91463C122340780075E219 /* MGMMD5.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB131222A4F200C864D8 /* MGMMD5.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91463D122340780075E219 /* MGMSHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBBD71222BC0600C864D8 /* MGMSHA1.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91463E122340780075E219 /* MGMSHA224.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB161222A4F200C864D8 /* MGMSHA224.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91463F122340780075E219 /* MGMSHA256.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB181222A4F200C864D8 /* MGMSHA256.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A914640122340780075E219 /* MGMSHA384.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1A1222A4F200C864D8 /* MGMSHA384.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A914641122340780075E219 /* MGMSHA512.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1C1222A4F200C864D8 /* MGMSHA512.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A914642122340850075E219 /* MGMMD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB141222A4F200C864D8 /* MGMMD5.m */; };
|
||||
2A914643122340850075E219 /* MGMSHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBBD81222BC0600C864D8 /* MGMSHA1.m */; };
|
||||
2A914644122340850075E219 /* MGMSHA224.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB171222A4F200C864D8 /* MGMSHA224.m */; };
|
||||
2A914645122340850075E219 /* MGMSHA256.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB191222A4F200C864D8 /* MGMSHA256.m */; };
|
||||
2A914646122340850075E219 /* MGMSHA384.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1B1222A4F200C864D8 /* MGMSHA384.m */; };
|
||||
2A914647122340850075E219 /* MGMSHA512.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1D1222A4F200C864D8 /* MGMSHA512.m */; };
|
||||
2A91464D122340DF0075E219 /* MGMMD.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A91445212230D880075E219 /* MGMMD.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91464E122340EB0075E219 /* MGMMD.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A91445312230D880075E219 /* MGMMD.m */; };
|
||||
2A914658122341260075E219 /* MGMMDTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB151222A4F200C864D8 /* MGMMDTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A914659122341260075E219 /* MGMMD5.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB131222A4F200C864D8 /* MGMMD5.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91465A122341260075E219 /* MGMSHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBBD71222BC0600C864D8 /* MGMSHA1.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91465B122341260075E219 /* MGMSHA224.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB161222A4F200C864D8 /* MGMSHA224.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91465C122341260075E219 /* MGMSHA256.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB181222A4F200C864D8 /* MGMSHA256.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91465D122341260075E219 /* MGMSHA384.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1A1222A4F200C864D8 /* MGMSHA384.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91465E122341260075E219 /* MGMSHA512.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A2CBB1C1222A4F200C864D8 /* MGMSHA512.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A91465F122341260075E219 /* MGMMD.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A91445212230D880075E219 /* MGMMD.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2A9146631223414B0075E219 /* MGMMD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB141222A4F200C864D8 /* MGMMD5.m */; };
|
||||
2A9146641223414B0075E219 /* MGMSHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBBD81222BC0600C864D8 /* MGMSHA1.m */; };
|
||||
2A9146651223414B0075E219 /* MGMSHA224.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB171222A4F200C864D8 /* MGMSHA224.m */; };
|
||||
2A9146661223414B0075E219 /* MGMSHA256.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB191222A4F200C864D8 /* MGMSHA256.m */; };
|
||||
2A9146671223414B0075E219 /* MGMSHA384.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1B1222A4F200C864D8 /* MGMSHA384.m */; };
|
||||
2A9146681223414B0075E219 /* MGMSHA512.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2CBB1D1222A4F200C864D8 /* MGMSHA512.m */; };
|
||||
2A9146691223414B0075E219 /* MGMMD.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A91445312230D880075E219 /* MGMMD.m */; };
|
||||
8DD76F9A0486AA7600D96B5E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.m */; settings = {ATTRIBUTES = (); }; };
|
||||
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
|
||||
8DD76F9F0486AA7600D96B5E /* MGMMD.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* MGMMD.1 */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
8DD76F9E0486AA7600D96B5E /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 8;
|
||||
dstPath = /usr/share/man/man1/;
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
8DD76F9F0486AA7600D96B5E /* MGMMD.1 in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 1;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
08FB7796FE84155DC02AAC07 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
2A2CBB131222A4F200C864D8 /* MGMMD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMMD5.h; sourceTree = "<group>"; };
|
||||
2A2CBB141222A4F200C864D8 /* MGMMD5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMMD5.m; sourceTree = "<group>"; };
|
||||
2A2CBB151222A4F200C864D8 /* MGMMDTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMMDTypes.h; sourceTree = "<group>"; };
|
||||
2A2CBB161222A4F200C864D8 /* MGMSHA224.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMSHA224.h; sourceTree = "<group>"; };
|
||||
2A2CBB171222A4F200C864D8 /* MGMSHA224.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMSHA224.m; sourceTree = "<group>"; };
|
||||
2A2CBB181222A4F200C864D8 /* MGMSHA256.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMSHA256.h; sourceTree = "<group>"; };
|
||||
2A2CBB191222A4F200C864D8 /* MGMSHA256.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMSHA256.m; sourceTree = "<group>"; };
|
||||
2A2CBB1A1222A4F200C864D8 /* MGMSHA384.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMSHA384.h; sourceTree = "<group>"; };
|
||||
2A2CBB1B1222A4F200C864D8 /* MGMSHA384.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMSHA384.m; sourceTree = "<group>"; };
|
||||
2A2CBB1C1222A4F200C864D8 /* MGMSHA512.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMSHA512.h; sourceTree = "<group>"; };
|
||||
2A2CBB1D1222A4F200C864D8 /* MGMSHA512.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMSHA512.m; sourceTree = "<group>"; };
|
||||
2A2CBBD71222BC0600C864D8 /* MGMSHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMSHA1.h; sourceTree = "<group>"; };
|
||||
2A2CBBD81222BC0600C864D8 /* MGMSHA1.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMSHA1.m; sourceTree = "<group>"; };
|
||||
2A91445212230D880075E219 /* MGMMD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMMD.h; sourceTree = "<group>"; };
|
||||
2A91445312230D880075E219 /* MGMMD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMMD.m; sourceTree = "<group>"; };
|
||||
2A9145F012233D690075E219 /* MGMMD.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MGMMD.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
2A9145F712233DB60075E219 /* Framework-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Framework-Info.plist"; sourceTree = "<group>"; };
|
||||
2A91460C12233E6A0075E219 /* libMGMMD.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMGMMD.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
2A914638122340590075E219 /* MGMMD.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = MGMMD.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
2A914655122341040075E219 /* libMGMMD.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMGMMD.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
32A70AAB03705E1F00C91783 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = "<group>"; };
|
||||
8DD76FA10486AA7600D96B5E /* MGMMD */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MGMMD; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C6859EA3029092ED04C91782 /* MGMMD.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = MGMMD.1; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
2A9145EE12233D690075E219 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A91460A12233E6A0075E219 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A914636122340590075E219 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A914653122341040075E219 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
8DD76F9B0486AA7600D96B5E /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
08FB7794FE84155DC02AAC07 /* MGMMD */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2A2CBB121222A4F200C864D8 /* Classes */,
|
||||
08FB7795FE84155DC02AAC07 /* Source */,
|
||||
2A9145F612233DB60075E219 /* Resources */,
|
||||
C6859EA2029092E104C91782 /* Documentation */,
|
||||
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */,
|
||||
);
|
||||
name = MGMMD;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB7795FE84155DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
32A70AAB03705E1F00C91783 /* Prefix.pch */,
|
||||
08FB7796FE84155DC02AAC07 /* main.m */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
08FB779EFE84155DC02AAC07 /* Foundation.framework */,
|
||||
);
|
||||
name = "External Frameworks and Libraries";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8DD76FA10486AA7600D96B5E /* MGMMD */,
|
||||
2A9145F012233D690075E219 /* MGMMD.framework */,
|
||||
2A91460C12233E6A0075E219 /* libMGMMD.a */,
|
||||
2A914638122340590075E219 /* MGMMD.dylib */,
|
||||
2A914655122341040075E219 /* libMGMMD.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
2A2CBB121222A4F200C864D8 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2A2CBB151222A4F200C864D8 /* MGMMDTypes.h */,
|
||||
2A2CBB131222A4F200C864D8 /* MGMMD5.h */,
|
||||
2A2CBB141222A4F200C864D8 /* MGMMD5.m */,
|
||||
2A2CBBD71222BC0600C864D8 /* MGMSHA1.h */,
|
||||
2A2CBBD81222BC0600C864D8 /* MGMSHA1.m */,
|
||||
2A2CBB161222A4F200C864D8 /* MGMSHA224.h */,
|
||||
2A2CBB171222A4F200C864D8 /* MGMSHA224.m */,
|
||||
2A2CBB181222A4F200C864D8 /* MGMSHA256.h */,
|
||||
2A2CBB191222A4F200C864D8 /* MGMSHA256.m */,
|
||||
2A2CBB1A1222A4F200C864D8 /* MGMSHA384.h */,
|
||||
2A2CBB1B1222A4F200C864D8 /* MGMSHA384.m */,
|
||||
2A2CBB1C1222A4F200C864D8 /* MGMSHA512.h */,
|
||||
2A2CBB1D1222A4F200C864D8 /* MGMSHA512.m */,
|
||||
2A91445212230D880075E219 /* MGMMD.h */,
|
||||
2A91445312230D880075E219 /* MGMMD.m */,
|
||||
);
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
2A9145F612233DB60075E219 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2A9145F712233DB60075E219 /* Framework-Info.plist */,
|
||||
);
|
||||
path = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C6859EA2029092E104C91782 /* Documentation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C6859EA3029092ED04C91782 /* MGMMD.1 */,
|
||||
);
|
||||
name = Documentation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
2A9145EB12233D690075E219 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A91460012233E450075E219 /* MGMMDTypes.h in Headers */,
|
||||
2A91460112233E450075E219 /* MGMMD5.h in Headers */,
|
||||
2A91460212233E450075E219 /* MGMSHA1.h in Headers */,
|
||||
2A91460312233E450075E219 /* MGMSHA224.h in Headers */,
|
||||
2A91460412233E450075E219 /* MGMSHA256.h in Headers */,
|
||||
2A91460512233E450075E219 /* MGMSHA384.h in Headers */,
|
||||
2A91460612233E450075E219 /* MGMSHA512.h in Headers */,
|
||||
2A91460712233E450075E219 /* MGMMD.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A91460812233E6A0075E219 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A91461412233F800075E219 /* MGMMDTypes.h in Headers */,
|
||||
2A91461512233F800075E219 /* MGMMD5.h in Headers */,
|
||||
2A91461612233F800075E219 /* MGMSHA1.h in Headers */,
|
||||
2A91461712233F800075E219 /* MGMSHA224.h in Headers */,
|
||||
2A91461812233F800075E219 /* MGMSHA256.h in Headers */,
|
||||
2A91461912233F800075E219 /* MGMSHA384.h in Headers */,
|
||||
2A91461A12233F800075E219 /* MGMSHA512.h in Headers */,
|
||||
2A91461B12233F800075E219 /* MGMMD.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A914634122340590075E219 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A91464D122340DF0075E219 /* MGMMD.h in Headers */,
|
||||
2A91463B122340780075E219 /* MGMMDTypes.h in Headers */,
|
||||
2A91463C122340780075E219 /* MGMMD5.h in Headers */,
|
||||
2A91463D122340780075E219 /* MGMSHA1.h in Headers */,
|
||||
2A91463E122340780075E219 /* MGMSHA224.h in Headers */,
|
||||
2A91463F122340780075E219 /* MGMSHA256.h in Headers */,
|
||||
2A914640122340780075E219 /* MGMSHA384.h in Headers */,
|
||||
2A914641122340780075E219 /* MGMSHA512.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A914651122341040075E219 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A914658122341260075E219 /* MGMMDTypes.h in Headers */,
|
||||
2A914659122341260075E219 /* MGMMD5.h in Headers */,
|
||||
2A91465A122341260075E219 /* MGMSHA1.h in Headers */,
|
||||
2A91465B122341260075E219 /* MGMSHA224.h in Headers */,
|
||||
2A91465C122341260075E219 /* MGMSHA256.h in Headers */,
|
||||
2A91465D122341260075E219 /* MGMSHA384.h in Headers */,
|
||||
2A91465E122341260075E219 /* MGMSHA512.h in Headers */,
|
||||
2A91465F122341260075E219 /* MGMMD.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
2A9145EF12233D690075E219 /* MGMMD Framework */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 2A9145F412233D6A0075E219 /* Build configuration list for PBXNativeTarget "MGMMD Framework" */;
|
||||
buildPhases = (
|
||||
2A9145EB12233D690075E219 /* Headers */,
|
||||
2A9145EC12233D690075E219 /* Resources */,
|
||||
2A9145ED12233D690075E219 /* Sources */,
|
||||
2A9145EE12233D690075E219 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "MGMMD Framework";
|
||||
productName = "MGMMD Framework";
|
||||
productReference = 2A9145F012233D690075E219 /* MGMMD.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
2A91460B12233E6A0075E219 /* MGMMD Touch */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 2A91460F12233E720075E219 /* Build configuration list for PBXNativeTarget "MGMMD Touch" */;
|
||||
buildPhases = (
|
||||
2A91460812233E6A0075E219 /* Headers */,
|
||||
2A91460912233E6A0075E219 /* Sources */,
|
||||
2A91460A12233E6A0075E219 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "MGMMD Touch";
|
||||
productName = "MGMMD Touch";
|
||||
productReference = 2A91460C12233E6A0075E219 /* libMGMMD.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
2A914637122340590075E219 /* MGMMD Dynamic Library */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 2A91464C1223409F0075E219 /* Build configuration list for PBXNativeTarget "MGMMD Dynamic Library" */;
|
||||
buildPhases = (
|
||||
2A914634122340590075E219 /* Headers */,
|
||||
2A914635122340590075E219 /* Sources */,
|
||||
2A914636122340590075E219 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "MGMMD Dynamic Library";
|
||||
productName = "MGMMD Dynamic Library";
|
||||
productReference = 2A914638122340590075E219 /* MGMMD.dylib */;
|
||||
productType = "com.apple.product-type.library.dynamic";
|
||||
};
|
||||
2A914654122341040075E219 /* MGMMD Static Library */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 2A9146621223413A0075E219 /* Build configuration list for PBXNativeTarget "MGMMD Static Library" */;
|
||||
buildPhases = (
|
||||
2A914651122341040075E219 /* Headers */,
|
||||
2A914652122341040075E219 /* Sources */,
|
||||
2A914653122341040075E219 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "MGMMD Static Library";
|
||||
productName = "MGMMD Static Library";
|
||||
productReference = 2A914655122341040075E219 /* libMGMMD.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
8DD76F960486AA7600D96B5E /* MGMMDTest */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "MGMMDTest" */;
|
||||
buildPhases = (
|
||||
8DD76F990486AA7600D96B5E /* Sources */,
|
||||
8DD76F9B0486AA7600D96B5E /* Frameworks */,
|
||||
8DD76F9E0486AA7600D96B5E /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = MGMMDTest;
|
||||
productInstallPath = "$(HOME)/bin";
|
||||
productName = MGMMD;
|
||||
productReference = 8DD76FA10486AA7600D96B5E /* MGMMD */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "MGMMD" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 08FB7794FE84155DC02AAC07 /* MGMMD */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8DD76F960486AA7600D96B5E /* MGMMDTest */,
|
||||
2A9145EF12233D690075E219 /* MGMMD Framework */,
|
||||
2A91460B12233E6A0075E219 /* MGMMD Touch */,
|
||||
2A914637122340590075E219 /* MGMMD Dynamic Library */,
|
||||
2A914654122341040075E219 /* MGMMD Static Library */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
2A9145EC12233D690075E219 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
2A9145ED12233D690075E219 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A9145F812233E1C0075E219 /* MGMMD5.m in Sources */,
|
||||
2A9145F912233E1C0075E219 /* MGMSHA1.m in Sources */,
|
||||
2A9145FA12233E1C0075E219 /* MGMSHA224.m in Sources */,
|
||||
2A9145FB12233E1C0075E219 /* MGMSHA256.m in Sources */,
|
||||
2A9145FC12233E1C0075E219 /* MGMSHA384.m in Sources */,
|
||||
2A9145FD12233E1C0075E219 /* MGMSHA512.m in Sources */,
|
||||
2A9145FE12233E1C0075E219 /* MGMMD.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A91460912233E6A0075E219 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A91461C12233F9E0075E219 /* MGMMD5.m in Sources */,
|
||||
2A91461D12233F9E0075E219 /* MGMSHA1.m in Sources */,
|
||||
2A91461E12233F9E0075E219 /* MGMSHA224.m in Sources */,
|
||||
2A91461F12233F9E0075E219 /* MGMSHA256.m in Sources */,
|
||||
2A91462012233F9E0075E219 /* MGMSHA384.m in Sources */,
|
||||
2A91462112233F9E0075E219 /* MGMSHA512.m in Sources */,
|
||||
2A91462212233F9E0075E219 /* MGMMD.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A914635122340590075E219 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A91464E122340EB0075E219 /* MGMMD.m in Sources */,
|
||||
2A914642122340850075E219 /* MGMMD5.m in Sources */,
|
||||
2A914643122340850075E219 /* MGMSHA1.m in Sources */,
|
||||
2A914644122340850075E219 /* MGMSHA224.m in Sources */,
|
||||
2A914645122340850075E219 /* MGMSHA256.m in Sources */,
|
||||
2A914646122340850075E219 /* MGMSHA384.m in Sources */,
|
||||
2A914647122340850075E219 /* MGMSHA512.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2A914652122341040075E219 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A9146631223414B0075E219 /* MGMMD5.m in Sources */,
|
||||
2A9146641223414B0075E219 /* MGMSHA1.m in Sources */,
|
||||
2A9146651223414B0075E219 /* MGMSHA224.m in Sources */,
|
||||
2A9146661223414B0075E219 /* MGMSHA256.m in Sources */,
|
||||
2A9146671223414B0075E219 /* MGMSHA384.m in Sources */,
|
||||
2A9146681223414B0075E219 /* MGMSHA512.m in Sources */,
|
||||
2A9146691223414B0075E219 /* MGMMD.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
8DD76F990486AA7600D96B5E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8DD76F9A0486AA7600D96B5E /* main.m in Sources */,
|
||||
2A2CBB1E1222A4F200C864D8 /* MGMMD5.m in Sources */,
|
||||
2A2CBB1F1222A4F200C864D8 /* MGMSHA224.m in Sources */,
|
||||
2A2CBB201222A4F200C864D8 /* MGMSHA256.m in Sources */,
|
||||
2A2CBB211222A4F200C864D8 /* MGMSHA384.m in Sources */,
|
||||
2A2CBB221222A4F200C864D8 /* MGMSHA512.m in Sources */,
|
||||
2A2CBBD91222BC0600C864D8 /* MGMSHA1.m in Sources */,
|
||||
2A91445412230D880075E219 /* MGMMD.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1DEB927508733DD40010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB927608733DD40010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
1DEB927908733DD40010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = (
|
||||
ppc,
|
||||
i386,
|
||||
x86_64,
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.4;
|
||||
"MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = macosx10.5;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB927A08733DD40010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = (
|
||||
ppc,
|
||||
i386,
|
||||
x86_64,
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.4;
|
||||
"MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = macosx10.5;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
2A9145F212233D6A0075E219 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
FRAMEWORK_VERSION = A;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INFOPLIST_FILE = "Resources/Framework-Info.plist";
|
||||
INSTALL_PATH = "$(HOME)/Library/Frameworks";
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
2A9145F312233D6A0075E219 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
FRAMEWORK_VERSION = A;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INFOPLIST_FILE = "Resources/Framework-Info.plist";
|
||||
INSTALL_PATH = "$(HOME)/Library/Frameworks";
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
2A91460D12233E6B0075E219 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
SDKROOT = iphoneos3.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
2A91460E12233E6B0075E219 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
SDKROOT = iphoneos3.2;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
2A9146391223405A0075E219 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INSTALL_PATH = /usr/local/lib;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
2A91463A1223405A0075E219 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INSTALL_PATH = /usr/local/lib;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
2A914656122341040075E219 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INSTALL_PATH = /usr/local/lib;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
2A914657122341040075E219 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INSTALL_PATH = /usr/local/lib;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = MGMMD;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "MGMMDTest" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB927508733DD40010E9CD /* Debug */,
|
||||
1DEB927608733DD40010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "MGMMD" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB927908733DD40010E9CD /* Debug */,
|
||||
1DEB927A08733DD40010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
2A9145F412233D6A0075E219 /* Build configuration list for PBXNativeTarget "MGMMD Framework" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
2A9145F212233D6A0075E219 /* Debug */,
|
||||
2A9145F312233D6A0075E219 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
2A91460F12233E720075E219 /* Build configuration list for PBXNativeTarget "MGMMD Touch" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
2A91460D12233E6B0075E219 /* Debug */,
|
||||
2A91460E12233E6B0075E219 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
2A91464C1223409F0075E219 /* Build configuration list for PBXNativeTarget "MGMMD Dynamic Library" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
2A9146391223405A0075E219 /* Debug */,
|
||||
2A91463A1223405A0075E219 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
2A9146621223413A0075E219 /* Build configuration list for PBXNativeTarget "MGMMD Static Library" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
2A914656122341040075E219 /* Debug */,
|
||||
2A914657122341040075E219 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
}
|
7
Prefix.pch
Normal file
7
Prefix.pch
Normal file
@ -0,0 +1,7 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'MGMMD' target in the 'MGMMD' project.
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
65
Readme.txt
Normal file
65
Readme.txt
Normal file
@ -0,0 +1,65 @@
|
||||
I (Mr. Gecko) went around the internet and found public domain implementations of some hash algorithms and decided to clean them up, make them look alike, and work alike so it's easy to use just by replacing the name with what algorithm you want. (NAMEInit, NAMEUpdate, Ect…)
|
||||
Because I'm a cocoa developer, I also added some cocoa apis such as MGMMD for accessing the algorithms via objective-c, and NSString/NSData add-on methods.
|
||||
|
||||
Hashing Algorithms Support so far.
|
||||
MD5
|
||||
SHA1
|
||||
SHA224
|
||||
SHA256
|
||||
SHA384
|
||||
SHA512
|
||||
|
||||
MGMMD Methods.
|
||||
+ (NSString *)stringHash:(NSString *)theString usingAlgorithm:(NSString *)theAlgorithm; - Hash a string with the given algorithm.
|
||||
+ (NSString *)fileHash:(NSString *)theFile usingAlgorithm:(NSString *)theAlgorithm; - Hash a file with the given algorithm.
|
||||
+ (NSString *)dataHash:(NSData *)theData usingAlgorithm:(NSString *)theAlgorithm; - Hash a NSData with the given algorithm.
|
||||
|
||||
+ (NSArray *)supportedAlgorithms; - Tells you the supported algorithms.
|
||||
|
||||
+ (id)mdWithAlgorithm:(NSString *)theAlgorithm; - Creates an instance of MGMMD with the algorithm given.
|
||||
- (id)initWithAlgorithm:(NSString *)theAlgorithm; - Initializes an instance of MGMMD with the algorithm given.
|
||||
|
||||
- (BOOL)updateWithString:(NSString *)theString; - Updates the context with a string.
|
||||
- (BOOL)updateWithFile:(NSString *)theFile; - Updates the context with a file.
|
||||
- (BOOL)updateWithData:(NSData *)theData; - Updates the context with a NSData.
|
||||
- (BOOL)updateWithBytes:(const char *)theBytes length:(int)theLength; - Updates the context with a c string.
|
||||
|
||||
- (NSData *)finalData; - Returns the final digest as NSData.
|
||||
- (const char *)finalBytes; - Returns the final digest as a c string.
|
||||
- (const char *)finalStringHash; - Returns the final hash as a c string.
|
||||
- (NSString *)finalHash; - Returns the final hash as a string.
|
||||
|
||||
Note: Once you call final*, it'll no longer be able to be updated. There is a MDNNAME (Replace NAME with algorithm) string that you are able to use to specify the algorithm.
|
||||
|
||||
C Functions. (Replace NAME with the name of the hash you want.)
|
||||
char *NAMEString(const char *string, int length); - Returns the hash of a c string as a c string. (Note: You have to free this.)
|
||||
char *NAMEFile(const char *path); - Returns the hash of a file as a cstring.
|
||||
|
||||
Raw access c functions.
|
||||
void NAMEInit(struct NAMEContext *context); - Initializes a context with the start data of the algorithm.
|
||||
void NAMEUpdate(struct NAMEContext *context, const unsigned char *buf, unsigned len); - Updates the context with a given c string.
|
||||
void NAMEFinal(unsigned char digest[NAMELength], struct NAMEContext *context); - Gets the final digest of the algorithm. (Note: The digest array length must be the length of the algorithm's digest. The length is specified in the defines as NAMELength.)
|
||||
|
||||
|
||||
Adding more algorithms.
|
||||
If you want to help me out and add more algorithms, please do, but keep these guide lines in mind.
|
||||
1. DO NOT STEAL CODE FROM AN OPEN SOURCE (That is not Public Domain) OR CLOSED SOURCE PROJECT UNLESS YOU OWN THAT PROJECT AND HAVE THE RIGHT TO MAKE THE CODE PUBLIC DOMAIN.
|
||||
2. ONLY PUBLIC DOMAIN CODE WILL BE ALLOWED AS WE DO NOT WANT COMPANIES/PEOPLE/ALIENS SAYING THAT WE STOLE THEIR CODE.
|
||||
3. You must mention who created the c algorithm as they'll appreciate it.
|
||||
4. You must follow my API rules or email me so I can make it follow the rules.
|
||||
5. Email the .m and .h files and I'll add it to the project and mention you in the file with the information your want or no information if you don't want to be mentioned.
|
||||
|
||||
Licenses.
|
||||
There is no licenses whatsoever, you may copy, redistribute, modify, sell, or hand it off to aliens. You are here by granted full power of the hash algorithms.
|
||||
|
||||
Warranties.
|
||||
Obviously there is no warranties just like every other software out there. I am just forced to say this just incase there are people out there who don't know this.
|
||||
|
||||
Compiling for C and C++.
|
||||
I have not tested this, but if you change the extension of the algorithm's .m file to .c or .cpp, you should be able to just compile with your projects and access the function part of the files. I added a if for the compiler to check if it's objective-c or c/c++ so it should just work out of the box.
|
||||
|
||||
Compiling Framework for Mac.
|
||||
Open MGMMD.xcodeproj in Xcode and change the configuration to release, target to MGMMD Framework, and compile.
|
||||
|
||||
Compiling Static Library for iPhone/iPod/iPad.
|
||||
Open MGMMD.xcodeproj in Xcode and change the configuration to release, target to MGMMD Touch, and compile.
|
22
Resources/Framework-Info.plist
Normal file
22
Resources/Framework-Info.plist
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
155
main.m
Normal file
155
main.m
Normal file
@ -0,0 +1,155 @@
|
||||
//
|
||||
// main.m
|
||||
//
|
||||
// Created by Mr. Gecko <GRMrGecko@gmail.com> on 2/23/10.
|
||||
// No Copyright Claimed. Public Domain.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MGMMD5.h"
|
||||
#import "MGMSHA1.h"
|
||||
#import "MGMSHA224.h"
|
||||
#import "MGMSHA256.h"
|
||||
#import "MGMSHA384.h"
|
||||
#import "MGMSHA512.h"
|
||||
#import "MGMMD.h"
|
||||
|
||||
int main (int argc, const char * argv[]) {
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString *correct = @"Hash is correct.";
|
||||
NSString *incorrect = @"Something is wrong, the hash is incorrect.";
|
||||
|
||||
NSString *MDString = @"Test String";
|
||||
NSString *hash;
|
||||
NSLog(@"Obj-C MD of %@", MDString);
|
||||
hash = [MDString MD5];
|
||||
NSLog(@"MD5: %@ %@", hash, ([hash isEqual:@"bd08ba3c982eaad768602536fb8e1184"] ? correct : incorrect));
|
||||
hash = [MDString SHA1];
|
||||
NSLog(@"SHA1: %@ %@", hash, ([hash isEqual:@"a5103f9c0b7d5ff69ddc38607c74e53d4ac120f2"] ? correct : incorrect));
|
||||
hash = [MDString SHA224];
|
||||
NSLog(@"SHA224: %@ %@", hash, ([hash isEqual:@"a4342acc574edb5032b8b0f0fc0edeb5e4d977ca8c87a60214c62c69"] ? correct : incorrect));
|
||||
hash = [MDString SHA256];
|
||||
NSLog(@"SHA256: %@ %@", hash, ([hash isEqual:@"30c6ff7a44f7035af933babaea771bf177fc38f06482ad06434cbcc04de7ac14"] ? correct : incorrect));
|
||||
hash = [MDString SHA384];
|
||||
NSLog(@"SHA384: %@ %@", hash, ([hash isEqual:@"d76a1b44f76d7cfe3f1cc244078de956a23a0b34adea1321ce67b188929719750979db66f793abdf4f87481ceb1cf931"] ? correct : incorrect));
|
||||
hash = [MDString SHA512];
|
||||
NSLog(@"SHA512: %@ %@", hash, ([hash isEqual:@"924bae629fbad5096a0a68929d5314d5b10b00108c5f9387c98d4c6cfe527a3cb6bba4303ed769c1feb38699800012b50c41e638bf0b47854f78344a3ac442a8"] ? correct : incorrect));
|
||||
|
||||
NSString *MDFile = [[NSBundle mainBundle] executablePath];
|
||||
//Change this to the path of the test file.
|
||||
MDFile = [[[[MDFile stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MDTest.bin"];
|
||||
NSLog(@"Obj-C File MD of %@", MDFile);
|
||||
hash = [MDFile pathMD5];
|
||||
NSLog(@"MD5: %@ %@", hash, ([hash isEqual:@"db393181e59d5b50c72bc582c505ab6f"] ? correct : incorrect));
|
||||
hash = [MDFile pathSHA1];
|
||||
NSLog(@"SHA1: %@ %@", hash, ([hash isEqual:@"deeed48d8e6b2c2cec878d12f241729a4158029a"] ? correct : incorrect));
|
||||
hash = [MDFile pathSHA224];
|
||||
NSLog(@"SHA224: %@ %@", hash, ([hash isEqual:@"4005eb91d5ce3a9555d359a401557ae1977546cfb246975d230674e1"] ? correct : incorrect));
|
||||
hash = [MDFile pathSHA256];
|
||||
NSLog(@"SHA256: %@ %@", hash, ([hash isEqual:@"db1c95c8679dc505dd71dccd1c5f9df86fe9dcb5d63f1689835fa6f24e062828"] ? correct : incorrect));
|
||||
hash = [MDFile pathSHA384];
|
||||
NSLog(@"SHA384: %@ %@", hash, ([hash isEqual:@"a6a1008686fcbfd55198038966fdbe6c0cc3faab7e9efc6c6394cee86601ff33ca1d54d2824bb577361aaa6aac4f8599"] ? correct : incorrect));
|
||||
hash = [MDFile pathSHA512];
|
||||
NSLog(@"SHA512: %@ %@", hash, ([hash isEqual:@"6801c0d3e7fdf43218e5f0986ee3e8dc33928a57470cffbde7ebdc23b454fb06024d5b0cba2646eaf58d8f53bb32eaff0d6a0ad7d97e8b4f607a181bd1bf7936"] ? correct : incorrect));
|
||||
|
||||
const char *MDChar = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
char *hashChar;
|
||||
NSLog(@"C MD of %s", MDChar);
|
||||
hashChar = MD5String(MDChar, strlen(MDChar));
|
||||
NSLog(@"MD5: %s %@", hashChar, (strcmp(hashChar, "e9b1713db620f1e3a14b6812de523f4b") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
hashChar = SHA1String(MDChar, strlen(MDChar));
|
||||
NSLog(@"SHA1: %s %@", hashChar, (strcmp(hashChar, "a26704c04fc5f10db5aab58468035531cc542485") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
hashChar = SHA224String(MDChar, strlen(MDChar));
|
||||
NSLog(@"SHA224: %s %@", hashChar, (strcmp(hashChar, "e6e4a6be069cc9bead8b6050856d2b26da6b3f7efa0951e5fb3a54dd") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
hashChar = SHA256String(MDChar, strlen(MDChar));
|
||||
NSLog(@"SHA256: %s %@", hashChar, (strcmp(hashChar, "74e7e5bb9d22d6db26bf76946d40fff3ea9f0346b884fd0694920fccfad15e33") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
hashChar = SHA384String(MDChar, strlen(MDChar));
|
||||
NSLog(@"SHA384: %s %@", hashChar, (strcmp(hashChar, "ce6d4ea5442bc6c830bea1942d4860db9f7b96f0e9d2c3073ffe47a0e1166d95612d840ff15e5efdd23c1f273096da32") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
hashChar = SHA512String(MDChar, strlen(MDChar));
|
||||
NSLog(@"SHA512: %s %@", hashChar, (strcmp(hashChar, "95cadc34aa46b9fdef432f62fe5bad8d9f475bfbecf797d5802bb5f2937a85d93ce4857a6262b03834c01c610d74cd1215f9a466dc6ad3dd15078e3309a03a6d") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
|
||||
const char *MDCharFile = [MDFile UTF8String];
|
||||
NSLog(@"C File MD of %s", MDCharFile);
|
||||
hashChar = MD5File(MDCharFile);
|
||||
if (hashChar!=NULL) {
|
||||
NSLog(@"MD5: %s %@", hashChar, (strcmp(hashChar, "db393181e59d5b50c72bc582c505ab6f") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
}
|
||||
hashChar = SHA1File(MDCharFile);
|
||||
if (hashChar!=NULL) {
|
||||
NSLog(@"SHA1: %s %@", hashChar, (strcmp(hashChar, "deeed48d8e6b2c2cec878d12f241729a4158029a") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
}
|
||||
hashChar = SHA224File(MDCharFile);
|
||||
if (hashChar!=NULL) {
|
||||
NSLog(@"SHA224: %s %@", hashChar, (strcmp(hashChar, "4005eb91d5ce3a9555d359a401557ae1977546cfb246975d230674e1") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
}
|
||||
hashChar = SHA256File(MDCharFile);
|
||||
if (hashChar!=NULL) {
|
||||
NSLog(@"SHA256: %s %@", hashChar, (strcmp(hashChar, "db1c95c8679dc505dd71dccd1c5f9df86fe9dcb5d63f1689835fa6f24e062828") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
}
|
||||
hashChar = SHA384File(MDCharFile);
|
||||
if (hashChar!=NULL) {
|
||||
NSLog(@"SHA384: %s %@", hashChar, (strcmp(hashChar, "a6a1008686fcbfd55198038966fdbe6c0cc3faab7e9efc6c6394cee86601ff33ca1d54d2824bb577361aaa6aac4f8599") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
}
|
||||
hashChar = SHA512File(MDCharFile);
|
||||
if (hashChar!=NULL) {
|
||||
NSLog(@"SHA512: %s %@", hashChar, (strcmp(hashChar, "6801c0d3e7fdf43218e5f0986ee3e8dc33928a57470cffbde7ebdc23b454fb06024d5b0cba2646eaf58d8f53bb32eaff0d6a0ad7d97e8b4f607a181bd1bf7936") ? incorrect : correct));
|
||||
free(hashChar);
|
||||
}
|
||||
|
||||
MGMMD *md;
|
||||
NSLog(@"File MGMMD of %@", MDFile);
|
||||
md = [MGMMD mdWithAlgorithm:@"MD5"];
|
||||
[md updateWithFile:MDFile];
|
||||
NSLog(@"MD5: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"db393181e59d5b50c72bc582c505ab6f"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA1"];
|
||||
[md updateWithFile:MDFile];
|
||||
NSLog(@"SHA1: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"deeed48d8e6b2c2cec878d12f241729a4158029a"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA224"];
|
||||
[md updateWithFile:MDFile];
|
||||
NSLog(@"SHA224: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"4005eb91d5ce3a9555d359a401557ae1977546cfb246975d230674e1"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA256"];
|
||||
[md updateWithFile:MDFile];
|
||||
NSLog(@"SHA256: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"db1c95c8679dc505dd71dccd1c5f9df86fe9dcb5d63f1689835fa6f24e062828"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA384"];
|
||||
[md updateWithFile:MDFile];
|
||||
NSLog(@"SHA384: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"a6a1008686fcbfd55198038966fdbe6c0cc3faab7e9efc6c6394cee86601ff33ca1d54d2824bb577361aaa6aac4f8599"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA512"];
|
||||
[md updateWithFile:MDFile];
|
||||
NSLog(@"SHA512: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"6801c0d3e7fdf43218e5f0986ee3e8dc33928a57470cffbde7ebdc23b454fb06024d5b0cba2646eaf58d8f53bb32eaff0d6a0ad7d97e8b4f607a181bd1bf7936"] ? correct : incorrect));
|
||||
|
||||
MDString = @"asdjl32j4lkjDS;:J;iaslkhjouh3hjsad89y45ioausf89sahuxzyLHuiyf8yHuyhiuash";
|
||||
NSLog(@"MGMMD of %@", MDString);
|
||||
md = [MGMMD mdWithAlgorithm:@"MD5"];
|
||||
[md updateWithString:MDString];
|
||||
NSLog(@"MD5: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"c204f2099b3c64057437889e40d6f1ba"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA1"];
|
||||
[md updateWithString:MDString];
|
||||
NSLog(@"SHA1: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"038e54bbf286cd1628145253a7afcdb63742db24"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA224"];
|
||||
[md updateWithString:MDString];
|
||||
NSLog(@"SHA224: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"aa0bf85004330e18856482c1aec134f51d91ac2a1c87cb2f11dc1283"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA256"];
|
||||
[md updateWithString:MDString];
|
||||
NSLog(@"SHA256: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"4b25724a05afaab26147179fdcfa7f7a81db0464d78072614a57e738b5bf1b0f"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA384"];
|
||||
[md updateWithString:MDString];
|
||||
NSLog(@"SHA384: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"665fc58df2e22ceafc373b0b951bd100a9e1f60fb68b4758ad88e32e5e5cbc02771c1a7cde672e7c5c6756860ce88a50"] ? correct : incorrect));
|
||||
md = [MGMMD mdWithAlgorithm:@"SHA512"];
|
||||
[md updateWithString:MDString];
|
||||
NSLog(@"SHA512: %@ %@", [md finalHash], ([[md finalHash] isEqual:@"1c58a65cf90dbeb31f8e4f196ce278936d70507cffea9682a9cbf79da9b046aebca9ed08c6f94d8e9f80cc4df0d5ddc65072cdb8a9b65d9e89b0fbf9bb0700ef"] ? correct : incorrect));
|
||||
|
||||
[pool drain];
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user