Skip to content

Instantly share code, notes, and snippets.

@xandrucea
Last active December 19, 2015 12:39
Show Gist options
  • Save xandrucea/5955961 to your computer and use it in GitHub Desktop.
Save xandrucea/5955961 to your computer and use it in GitHub Desktop.
// replace chars
validDeviceToken = [validDeviceToken stringByReplacingOccurrencesOfString:@"<" withString:@""];
Cut whitespaces from string
---------------------------
[myString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
Extensions for Categories
__________________________
Create MD5 Hash
---------------
1. import <CommonCrypto/CommonDigest.h>
2. insert message
+ (NSString*)md5HexDigest:(NSString*)input{
const char* str = [input UTF8String];
unsigned char result[30];
CC_MD5(str, strlen(str), result);
NSMutableString *ret = [NSMutableString stringWithCapacity:30*2];
for(int i = 0; i <30; i++) {
[ret appendFormat:@"%02x",result[i]];
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment