Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/MD5/Objective-C/md5-1.m
Normal file
3
Task/MD5/Objective-C/md5-1.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
NSString *myString = @"The quick brown fox jumped over the lazy dog's back";
|
||||
NSData *digest = [[myString dataUsingEncoding:NSUTF8StringEncoding] md5Digest]; // or another encoding of your choosing
|
||||
NSLog(@"%@", [digest hexadecimalRepresentation]);
|
||||
12
Task/MD5/Objective-C/md5-2.m
Normal file
12
Task/MD5/Objective-C/md5-2.m
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#import <CommonCrypto/CommonDigest.h>
|
||||
|
||||
NSString *myString = @"The quick brown fox jumped over the lazy dog's back";
|
||||
NSData *data = [myString dataUsingEncoding:NSUTF8StringEncoding]; // or another encoding of your choosing
|
||||
unsigned char digest[CC_MD5_DIGEST_LENGTH];
|
||||
if (CC_MD5([data bytes], [data length], digest)) {
|
||||
NSMutableString *hex = [NSMutableString string];
|
||||
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
|
||||
[hex appendFormat: @"%02x", (int)(digest[i])];
|
||||
}
|
||||
NSLog(@"%@", hex);
|
||||
}
|
||||
12
Task/MD5/Objective-C/md5-3.m
Normal file
12
Task/MD5/Objective-C/md5-3.m
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <openssl/md5.h>
|
||||
|
||||
NSString *myString = @"The quick brown fox jumped over the lazy dog's back";
|
||||
NSData *data = [myString dataUsingEncoding:NSUTF8StringEncoding]; // or another encoding of your choosing
|
||||
unsigned char digest[MD5_DIGEST_LENGTH];
|
||||
if (MD5([data bytes], [data length], digest)) {
|
||||
NSMutableString *hex = [NSMutableString string];
|
||||
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
|
||||
[hex appendFormat: @"%02x", (int)(digest[i])];
|
||||
}
|
||||
NSLog(@"%@", hex);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue