-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNSString+MD5.m
More file actions
28 lines (23 loc) · 805 Bytes
/
NSString+MD5.m
File metadata and controls
28 lines (23 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// NSString+MD5.m
// MarvelApp
//
// Created by Юрий Логинов on 22.06.17.
// Copyright © 2017 Юрий Логинов. All rights reserved.
//
#import "NSString+MD5.h"
#import <CommonCrypto/CommonCrypto.h>
@implementation NSString (MD5)
- (NSString *)MD5String {
const char *cStr = [self UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5( cStr, (CC_LONG)strlen(cStr), result );
return [NSString stringWithFormat:
@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
];
}
@end