#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>

@interface Helpers : NSObject

@property(nonatomic,strong)NSDateFormatter *h_dateFormatter;

@property(nonatomic,strong)NSDateComponents *h_components;

+(BOOL)strIsEmty:(NSString *)str;

+(NSString *)getPathByMain:(NSString *)name

type:(NSString *)tp;

+ (NSString *)getPath:(NSString *)fileName;

+(BOOL)fileIsExit:(NSString *)path;

+(BOOL)deleteFile:(NSString *)path;

+(BOOL)dicIsExit:(NSString *)path;

+(BOOL)createFile:(NSString *)url

data:(NSData *)data;

+(BOOL)createDic:(NSString *)url;

+(NSString *)getNowStr;

+(int)getNowYear;

+(NSString *)getDateStr:(NSDate *)date;

+(NSDate *)getDateByString:(NSString *)str;

+(NSString *)getDateStrFromDate:(NSDate *)date bySeconds:(double)seconds;

+(NSDictionary *)getDateInfoForDate:(NSDate *)date;

+ (NSString *)convertToDateString:(NSDate *)date

withFormat:(NSString *)dateFormat;

+(NSString *)URLEncodedString:(NSString *)str;

+(NSString *)URLDecodedString:(NSString *)str;

+(BOOL)strIsChecked:(NSString *)str

checkStr:(NSString *)checkStr;

+(BOOL)objIsNull:(id)obj;

+(NSString *)inputStr:(id)ipStr;

+(BOOL)strIsEmail:(NSString *)targetStr;

+(BOOL)strIsMobileOrEmail:(NSString *)targetStr;

+(BOOL)strIsWordorNum:(NSString *)targetStr;

+(BOOL)strIsChinaWord:(NSString *)targetStr;

+(BOOL)strIsPassword:(NSString *)targetStr;

+(BOOL)strIsInLen:(int)tLen targetStr:(NSString *)tStr;

#pragma mark -

#pragma mark base64 string 加密以及解密

#define __BASE64( text )        [CommonFunc base64StringFromText:text]

#define __TEXT( base64 )        [CommonFunc textFromBase64String:base64]

/******************************************************************************

函数名称 : + (NSString *)base64StringFromText:(NSString *)text

函数描述 : 将文本转换为base64格式字符串

输入参数 : (NSString *)text    文本

输出参数 : N/A

返回参数 : (NSString *)    base64格式字符串

备注信息 :

******************************************************************************/

+ (NSString *)base64StringFromText:(NSString *)text;

/******************************************************************************

函数名称 : + (NSString *)textFromBase64String:(NSString *)base64

函数描述 : 将base64格式字符串转换为文本

输入参数 : (NSString *)base64  base64格式字符串

输出参数 : N/A

返回参数 : (NSString *)    文本

备注信息 :

******************************************************************************/

+ (NSString *)textFromBase64String:(NSString *)base64;

//分分秒秒

+ (NSString *)timeFormattedMMSS:(int)totalSeconds;

//时时分分秒秒

+ (NSString *)timeFormattedHHMMSS:(int)totalSeconds;

//通过字典串返回cgrect

+ (CGRect )strForCgrect:(NSDictionary *)dic;

//检测首字母不能为数字,中英文

+ (BOOL)strIsIllegal:(NSString *)targetStr;

//检测手机号

+ (BOOL)strIsMobile:(NSString *)targetStr;

//判断int数是否小于10,如果小于10 拼接0~

+ (NSString *)intIsLessThanTen:(int)little;

//是否包涵空格

+ (BOOL)stringIsContainBlank:(NSString *)targetStr;

//保存数据

+ (void)nsuserDefaultSetvalueWithKey:(NSString *)key Value:(NSString *)value;

//读取数据

+ (NSString *)nsuserDefaultObjectForKeyWithKey:(NSString *)key;

@end

#import "Helpers.h"

#import <CommonCrypto/CommonCryptor.h>

#import <UIKit/UIKit.h>

static NSDateFormatter *dateFormatter = nil;

@implementation Helpers

+(BOOL)strIsEmty:(NSString *)str

{

if (str == nil || str == NULL) {

return YES;

}

if ([str isKindOfClass:[NSNull class]]) {

return YES;

}

if (str.length == 0) {

return YES;

}

return NO;

}

+(NSString *)getPathByMain:(NSString *)name

type:(NSString *)tp

{

return [[NSBundle mainBundle] pathForResource:name ofType:tp];

}

+ (NSString *)getPath:(NSString *)fileName

{

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

return  [[paths objectAtIndex:0] stringByAppendingPathComponent:fileName];

}

+(BOOL)fileIsExit:(NSString *)path

{

NSFileManager *_fm = [NSFileManager defaultManager];

BOOL _flag = NO;

if (path) {

return [_fm fileExistsAtPath:path isDirectory:&_flag];

}else{

return NO;

}

}

+(BOOL)deleteFile:(NSString *)path

{

NSFileManager *_fm = [NSFileManager defaultManager];

if (path) {

return [_fm removeItemAtPath:path error:nil];

}else{

return NO;

}

}

+(BOOL)dicIsExit:(NSString *)path

{

NSFileManager *_fm = [NSFileManager defaultManager];

if (path) {

BOOL _flag = YES;

return [_fm fileExistsAtPath:path isDirectory:&_flag];

}else{

return NO;

}

}

+(BOOL)createFile:(NSString *)url

data:(NSData *)data

{

if (url && data) {

NSFileManager   *_fm = [NSFileManager defaultManager];

return [_fm createFileAtPath:url contents:data attributes:nil];

}else{

return NO;

}

}

+(BOOL)createDic:(NSString *)url

{

if (url) {

NSFileManager   *_fm = [NSFileManager defaultManager];

return [_fm createDirectoryAtPath:url

withIntermediateDirectories:YES

attributes:nil

error:nil];

}else{

return NO;

}

}

+(NSString *)getDateStrFromDate:(NSDate *)date

bySeconds:(double)seconds

{

NSDateComponents *components = [[NSCalendar currentCalendar] components:

NSDayCalendarUnit |

NSMonthCalendarUnit |

NSYearCalendarUnit |

NSHourCalendarUnit |

NSMinuteCalendarUnit |

NSSecondCalendarUnit

fromDate:[NSDate dateWithTimeInterval:seconds sinceDate:date]];

return [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d",

(int)[components year],

(int)[components month],

(int)[components day],

(int)[components hour],

(int)[components minute],

(int)[components second]

];

}

+(NSDictionary *)getDateInfoForDate:(NSDate *)date

{

if (date) {

NSDateComponents *components = [[NSCalendar currentCalendar] components:

NSDayCalendarUnit |

NSMonthCalendarUnit |

NSYearCalendarUnit |

NSHourCalendarUnit |

NSMinuteCalendarUnit |

NSSecondCalendarUnit |

NSWeekdayCalendarUnit

fromDate:date];

return @{

@"year":[NSString stringWithFormat:@"%04d",(int)[components year]],

@"month":[NSString stringWithFormat:@"%02d",(int)[components month]],

@"day":[NSString stringWithFormat:@"%02d",(int)[components day]],

@"hour":[NSString stringWithFormat:@"%02d",(int)[components hour]],

@"minute":[NSString stringWithFormat:@"%02d",(int)[components minute]],

@"second":[NSString stringWithFormat:@"%02d",(int)[components second]],

@"weekday":[NSString stringWithFormat:@"%d",(int)[components weekday]]

};

}

else{

return nil;

}

}

+(NSString *)getNowStr

{

NSDateComponents *components = [[NSCalendar currentCalendar] components:

NSDayCalendarUnit |

NSMonthCalendarUnit |

NSYearCalendarUnit |

NSHourCalendarUnit |

NSMinuteCalendarUnit |

NSSecondCalendarUnit

fromDate:[NSDate date]];

return [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d",

(int)[components year],

(int)[components month],

(int)[components day],

(int)[components hour],

(int)[components minute],

(int)[components second]

];

}

+(int)getNowYear

{

NSDateComponents *components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit

fromDate:[NSDate date]];

return (int)[components year];

}

+(NSString *)getDateStr:(NSDate *)date

{

NSDateComponents *components = [[NSCalendar currentCalendar] components:

NSDayCalendarUnit |

NSMonthCalendarUnit |

NSYearCalendarUnit |

NSHourCalendarUnit |

NSMinuteCalendarUnit |

NSSecondCalendarUnit

fromDate:date ];

return [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d",

(int)[components year],

(int)[components month],

(int)[components day],

(int)[components hour],

(int)[components minute],

(int)[components second]

];

}

+(NSDate *)getDateByString:(NSString *)str

{

if ( str == nil || [@"" isEqualToString:str]) {

str = @"1970-01-01 00:00:00";

}

if (!dateFormatter) {

dateFormatter = [[NSDateFormatter alloc] init];

}

[dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"];

return [dateFormatter dateFromString:str];

}

+ (NSString *)convertToDateString:(NSDate *)date

withFormat:(NSString *)dateFormat

{

if (!dateFormatter) {

dateFormatter = [[NSDateFormatter alloc] init];

}

[dateFormatter setDateFormat:dateFormat];

//    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT{8}"]];

return [dateFormatter stringFromDate:date];

}

+(BOOL)strIsChecked:(NSString *)str

checkStr:(NSString *)checkStr

{

BOOL _flag = NO;

if (str && ![str isEqual:[NSNull null]]) {

//NSString *_checkStr = @"^[0-9]{3}$";

//@"^[0-9]+-*[0-9]+$";

NSRegularExpression *regex2 = [NSRegularExpression regularExpressionWithPattern:checkStr

options:0

error:nil];

if (regex2){//对象进行匹配

NSTextCheckingResult *result2 = [regex2 firstMatchInString:str

options:0

range:NSMakeRange(0, str.length)];

if (result2)  {

_flag = YES;

}

}

}

return _flag;

}

+(NSString *)URLEncodedString:(NSString *)str

{

NSString *result = (__bridge_transfer NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,

(CFStringRef)str,

NULL,

CFSTR("!*'();:@&=+$,/?%#[]"),

kCFStringEncodingUTF8);

return result;

}

+(NSString *)URLDecodedString:(NSString *)str

{

NSString *result = (__bridge_transfer NSString*)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,

(CFStringRef)str,

CFSTR(""),

kCFStringEncodingUTF8);

return result;

}

+(BOOL)objIsNull:(id)obj

{

BOOL _flag = YES;

if (obj && ![obj isEqual:[NSNull null]]) {

_flag = NO;

}

return _flag;

}

+(NSString *)inputStr:(id)ipStr

{

NSString *_result = @"";

if (ipStr == nil || ipStr == NULL) {

return _result = @"";

}

if ([ipStr isKindOfClass:[NSNull class]]) {

return _result = @"";

}

if ([ipStr isKindOfClass:[NSString class]]) {

_result = ipStr;

}

if ([ipStr isKindOfClass:[NSNumber class]]) {

_result = [(NSNumber *)ipStr stringValue];

}

return _result;

}

+(BOOL)strIsMobileOrEmail:(NSString *)targetStr

{

BOOL _flag = NO;

//匹配6-15个由字母/数字组成的字符串的正则表达式:

NSString *_phoneNumRegex = @"1[0-9]{10}";

//匹配邮箱格式

NSString *_emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";

NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _phoneNumRegex];

if ([_pred evaluateWithObject:targetStr]) {

_flag = YES;

}

else{

_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];

if ([_pred evaluateWithObject:targetStr]) {

_flag = YES;

}

}

return _flag;

}

+ (BOOL)strIsMobile:(NSString *)targetStr

{

BOOL _flag = NO;

NSString *_phoneNum = @"1[0-9]{10}";

NSPredicate *_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",_phoneNum];

if ([_pre evaluateWithObject:targetStr]) {

_flag = YES;

}

return _flag;

}

+ (BOOL)strIsPassword:(NSString *)targetStr

{

//长度小于等于6

if (targetStr.length < 6) {

return NO;

} else if ([targetStr rangeOfString:@"@"].length > 0){//包含特殊字符@

return  NO;

} else if (targetStr.length >= 16) {//大于等于16

return NO;

} else {

return  YES;

}

}

+(BOOL)strIsEmail:(NSString *)targetStr

{

BOOL _flag = NO;

//匹配邮箱格式

NSString *_emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";

NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];

if ([_pred evaluateWithObject:targetStr]) {

_flag = YES;

}

return _flag;

}

+(BOOL)strIsWordorNum:(NSString *)targetStr

{

BOOL _flag = NO;

NSString *_emailRegex = @"[A-Z0-9a-z\u4e00-\u9fa5]*";

NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];

if ([_pred evaluateWithObject:targetStr]) {

_flag = YES;

}

return _flag;

}

//检测首字母不能为数字,长度不能大于12字节,中英文

+ (BOOL)strIsIllegal:(NSString *)targetStr

{

BOOL _flag = NO;

NSString *_userName = @"^[^0-9][A-Za-z0-9_\u4e00-\u9fa5]*";

NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _userName];

if ([_pred evaluateWithObject:targetStr]) {

_userName = @"^[A-Za-z0-9_\u4e00-\u9fa5]*";

NSPredicate *_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _userName];

if ([_pre evaluateWithObject:targetStr]) {

_flag = YES;

}

}

return _flag;

}

+(BOOL)strIsChinaWord:(NSString *)targetStr

{

BOOL _flag = NO;

NSString *_emailRegex = @"[\u4e00-\u9fa5]*";

NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];

if ([_pred evaluateWithObject:targetStr]) {

_flag = YES;

}

return _flag;

}

//判断是否在多少字符之内

+(BOOL)strIsInLen:(int)tLen

targetStr:(NSString *)tStr

{

BOOL _flag  = NO;

int _sLen   = 0;

NSString *_tStr = [Helpers inputStr:tStr];

long l = 0;

if (![@"" isEqualToString:_tStr]) {

for (int i = 0; i < _tStr.length; i++) {

NSString *_s = [_tStr substringWithRange:NSMakeRange(i, 1)];

l = strlen([_s cStringUsingEncoding:NSUTF8StringEncoding]);

if (l == 1) {

_sLen++;

}

else if(l == 3)

{

_sLen += 2;

}

else{

_sLen = tLen + 1;

break;

}

}

}

if (_sLen <= tLen && _sLen != 0) {

_flag = YES;

}

return _flag;

}

//空字符串

#define     LocalStr_None           @""

static const char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

+ (NSString *)base64StringFromText:(NSString *)text

{

if (text && ![text isEqualToString:LocalStr_None]) {

//取项目的bundleIdentifier作为KEY  改动了此处

//NSString *key = [[NSBundle mainBundle] bundleIdentifier];

NSData *data = [text dataUsingEncoding:NSUTF8StringEncoding];

//IOS 自带DES加密 Begin  改动了此处

//data = [self DESEncrypt:data WithKey:key];

//IOS 自带DES加密 End

return [self base64EncodedStringFrom:data];

}

else {

return LocalStr_None;

}

}

+ (NSString *)textFromBase64String:(NSString *)base64

{

if (base64 && ![base64 isEqualToString:LocalStr_None]) {

//取项目的bundleIdentifier作为KEY   改动了此处

//NSString *key = [[NSBundle mainBundle] bundleIdentifier];

NSData *data = [self dataWithBase64EncodedString:base64];

//IOS 自带DES解密 Begin    改动了此处

//data = [self DESDecrypt:data WithKey:key];

//IOS 自带DES加密 End

return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

}

else {

return LocalStr_None;

}

}

/******************************************************************************

函数名称 : + (NSData *)DESEncrypt:(NSData *)data WithKey:(NSString *)key

函数描述 : 文本数据进行DES加密

输入参数 : (NSData *)data

(NSString *)key

输出参数 : N/A

返回参数 : (NSData *)

备注信息 : 此函数不可用于过长文本

******************************************************************************/

+ (NSData *)DESEncrypt:(NSData *)data WithKey:(NSString *)key

{

char keyPtr[kCCKeySizeAES256+1];

bzero(keyPtr, sizeof(keyPtr));

[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];

NSUInteger dataLength = [data length];

size_t bufferSize = dataLength + kCCBlockSizeAES128;

void *buffer = malloc(bufferSize);

size_t numBytesEncrypted = 0;

CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmDES,

kCCOptionPKCS7Padding | kCCOptionECBMode,

keyPtr, kCCBlockSizeDES,

NULL,

[data bytes], dataLength,

buffer, bufferSize,

&numBytesEncrypted);

if (cryptStatus == kCCSuccess) {

return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];

}

free(buffer);

return nil;

}

/******************************************************************************

函数名称 : + (NSData *)DESEncrypt:(NSData *)data WithKey:(NSString *)key

函数描述 : 文本数据进行DES解密

输入参数 : (NSData *)data

(NSString *)key

输出参数 : N/A

返回参数 : (NSData *)

备注信息 : 此函数不可用于过长文本

******************************************************************************/

+ (NSData *)DESDecrypt:(NSData *)data WithKey:(NSString *)key

{

char keyPtr[kCCKeySizeAES256+1];

bzero(keyPtr, sizeof(keyPtr));

[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];

NSUInteger dataLength = [data length];

size_t bufferSize = dataLength + kCCBlockSizeAES128;

void *buffer = malloc(bufferSize);

size_t numBytesDecrypted = 0;

CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmDES,

kCCOptionPKCS7Padding | kCCOptionECBMode,

keyPtr, kCCBlockSizeDES,

NULL,

[data bytes], dataLength,

buffer, bufferSize,

&numBytesDecrypted);

if (cryptStatus == kCCSuccess) {

return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted];

}

free(buffer);

return nil;

}

/******************************************************************************

函数名称 : + (NSData *)dataWithBase64EncodedString:(NSString *)string

函数描述 : base64格式字符串转换为文本数据

输入参数 : (NSString *)string

输出参数 : N/A

返回参数 : (NSData *)

备注信息 :

******************************************************************************/

+ (NSData *)dataWithBase64EncodedString:(NSString *)string

{

if (string == nil)

[NSException raise:NSInvalidArgumentException format:nil];

if ([string length] == 0)

return [NSData data];

static char *decodingTable = NULL;

if (decodingTable == NULL)

{

decodingTable = malloc(256);

if (decodingTable == NULL)

return nil;

memset(decodingTable, CHAR_MAX, 256);

NSUInteger i;

for (i = 0; i < 64; i++)

decodingTable[(short)encodingTable[i]] = i;

}

const char *characters = [string cStringUsingEncoding:NSASCIIStringEncoding];

if (characters == NULL)     //  Not an ASCII string!

return nil;

char *bytes = malloc((([string length] + 3) / 4) * 3);

if (bytes == NULL)

return nil;

NSUInteger length = 0;

NSUInteger i = 0;

while (YES)

{

char buffer[4];

short bufferLength;

for (bufferLength = 0; bufferLength < 4; i++)

{

if (characters[i] == '\0')

break;

if (isspace(characters[i]) || characters[i] == '=')

continue;

buffer[bufferLength] = decodingTable[(short)characters[i]];

if (buffer[bufferLength++] == CHAR_MAX)      //  Illegal character!

{

free(bytes);

return nil;

}

}

if (bufferLength == 0)

break;

if (bufferLength == 1)      //  At least two characters are needed to produce one byte!

{

free(bytes);

return nil;

}

//  Decode the characters in the buffer to bytes.

bytes[length++] = (buffer[0] << 2) | (buffer[1] >> 4);

if (bufferLength > 2)

bytes[length++] = (buffer[1] << 4) | (buffer[2] >> 2);

if (bufferLength > 3)

bytes[length++] = (buffer[2] << 6) | buffer[3];

}

bytes = realloc(bytes, length);

return [NSData dataWithBytesNoCopy:bytes length:length];

}

/******************************************************************************

函数名称 : + (NSString *)base64EncodedStringFrom:(NSData *)data

函数描述 : 文本数据转换为base64格式字符串

输入参数 : (NSData *)data

输出参数 : N/A

返回参数 : (NSString *)

备注信息 :

******************************************************************************/

+ (NSString *)base64EncodedStringFrom:(NSData *)data

{

if ([data length] == 0)

return @"";

char *characters = malloc((([data length] + 2) / 3) * 4);

if (characters == NULL)

return nil;

NSUInteger length = 0;

NSUInteger i = 0;

while (i < [data length])

{

char buffer[3] = {0,0,0};

short bufferLength = 0;

while (bufferLength < 3 && i < [data length])

buffer[bufferLength++] = ((char *)[data bytes])[i++];

//  Encode the bytes in the buffer to four characters, including padding "=" characters if necessary.

characters[length++] = encodingTable[(buffer[0] & 0xFC) >> 2];

characters[length++] = encodingTable[((buffer[0] & 0x03) << 4) | ((buffer[1] & 0xF0) >> 4)];

if (bufferLength > 1)

characters[length++] = encodingTable[((buffer[1] & 0x0F) << 2) | ((buffer[2] & 0xC0) >> 6)];

else characters[length++] = '=';

if (bufferLength > 2)

characters[length++] = encodingTable[buffer[2] & 0x3F];

else characters[length++] = '=';

}

return [[NSString alloc] initWithBytesNoCopy:characters length:length encoding:NSASCIIStringEncoding freeWhenDone:YES];

}

//分分秒秒

+ (NSString *)timeFormattedMMSS:(int)totalSeconds

{

int seconds = totalSeconds % 60;

int minutes = totalSeconds / 60;

return [NSString stringWithFormat:@"%02d:%02d",minutes, seconds];

}

//时时分分秒秒

+ (NSString *)timeFormattedHHMMSS:(int)totalSeconds

{

int seconds = totalSeconds % 60;

int minutes = (totalSeconds / 60) % 60;

int hours = totalSeconds / 3600;

return [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds];

}

//将"60_20_200_30"返回一个cgrect

+ (CGRect )strForCgrect:(NSString *)str

{

//    NSMutableDictionary *_result = [@{}mutableCopy];

CGRect frame = CGRectZero;

if (str) {

NSString *_fFrameStr = str;

if (_fFrameStr) {

CGRect _fra = CGRectZero;

NSArray *_frameAry = [_fFrameStr componentsSeparatedByString:@"_"];

float _x = 0;

float _y = 0;

float _fx = 0;

float _fy = 0;

_x = [(NSString *)_frameAry[0] floatValue];

_y = [(NSString *)_frameAry[1] floatValue];

_fx = [(NSString *)_frameAry[2] floatValue];

_fy = [(NSString *)_frameAry[3] floatValue];

_fra = CGRectMake(_x, _y, _fx, _fy);

frame = _fra;

}

}

return frame;

}

//判断int数是否小于10,如果小于10 拼接0~

+ (NSString *)intIsLessThanTen:(int)little

{

NSString *resultString = @"";

if (little < 10) {

resultString = [NSString stringWithFormat:@"0%d",little];

}else

{

resultString = [NSString stringWithFormat:@"%d",little];

}

return resultString;

}

//是否包涵空格

+ (BOOL)stringIsContainBlank:(NSString *)targetStr

{

BOOL _flag = NO;

if ([targetStr containsString:@" "]) {

_flag = YES;

}else

{

_flag = NO;

}

return _flag;

}

//保存数据

+ (void)nsuserDefaultSetvalueWithKey:(NSString *)key Value:(NSString *)value

{

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

[userDefaults setValue:value forKey:key];

}

//读取数据

+ (NSString *)nsuserDefaultObjectForKeyWithKey:(NSString *)key

{

NSString *resultString = [NSString string];

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

resultString = [userDefaults objectForKey:key];

return resultString;

}

@end

ios 加密解密工具类字符判断等的更多相关文章

  1. Base64加密解密工具类

    使用Apache commons codec类Base64进行加密解密 maven依赖 <dependency> <groupId>commons-codec</grou ...

  2. .Net(c#)加密解密工具类:

    /// <summary> /// .Net加密解密帮助类 /// </summary> public class NetCryptoHelper { #region des实 ...

  3. java加密解密工具类

    package com.founder.mrp.util; import java.nio.charset.StandardCharsets; import java.security.Key; im ...

  4. AES加密解密工具类封装(AESUtil)

    package club.codeapes.common.utils; import org.springframework.util.Base64Utils; import javax.crypto ...

  5. 加密解密工具类(Java,DES)

    一个Java版的DES加密工具类,能够用来进行网络传输数据加密,保存password的时候进行加密. import java.security.Key; import java.security.sp ...

  6. java 加密解密工具类(实用!!!)

    最近发现了一个加密解密的好例子,很方便使用,可以作为平时开发的工具集,记录一下. package com.sh.springboottdemo2.util; import com.sun.org.ap ...

  7. des 加密解密工具类

    最近在做des的双对称加密解密,特此记录一下. des对称加密,是一种比较传统的加密方式,其加密运算.解密运算使用的是同样的密钥,信息的发送者和信息的接收者在进行信息的传输与处理时,必须共同持有该密码 ...

  8. 自写AES加密解密工具类

    此类主要用于加密与解密,采用128位ECB模式,PKCS5Padding填充补位. 可使用方法为加密返回二进制encryptBin(content, key).加密返回十六进制encryptHex(c ...

  9. Java-DES算法加密解密工具类

    import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import ...

随机推荐

  1. Jenkins的持续集成

    持续集成:不需要人工干预,持久化.重复的运行一个任务.将代码自动的更新到最新,然后自动运行. 新建项目之前要再Jenkins的全局工具配置里面把git的路径设置好.[全局工具配置]-->[Git ...

  2. 已有模板与tp框架的结合 (前台)

    已有模板与tp框架的结合 具体步骤   A.复制模板文件到view指定目录 B. 复合css .js.img.静态资源文件到系统指定目录 C. 把静态资源(css,js,img)文件的路径设置为“常量 ...

  3. C Strange Sorting

    C. Strange Sorting time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. python安装mysql-python1.2.5

    首先安装好python 然后安装C++ Microsoft Visual C++ Compiler for Python 2.7 下载后双击安装 登录https://pypi.python.org/p ...

  5. 2017-2018-1 JaWorld 第三周作业

    2017-2018-1 JaWorld 第三周作业 团队展示 队员学号 队名 团队项目描述 队员风采 团队的特色 团队合照 团队初步合作 前两周的反思与总结 需要改进的地方 团队选题 *采访老师或有开 ...

  6. 学习Zookeeper之第2章Zookeeper安装

    第 2 章 Zookeeper安装 2.1 本地模式安装部署 2.2 配置参数解读 第 2 章 Zookeeper安装 2.1 本地模式安装部署 1)安装前准备: (1)安装 jdk (2)通过 fi ...

  7. POJ 3268 Silver Cow Party(最短路&Dijkstra)题解

    题意:有n个地点,有m条路,问从所有点走到指定点x再走回去的最短路中的最长路径 思路:用Floyd超时的,这里用的Dijkstra. Dijkstra感觉和Prim和Kruskal的思路很像啊.我们把 ...

  8. 51Nod 1509 加长棒(隔板法)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1509 思路: 直接去解可行的方法有点麻烦,所以应该用总的方法去减去不可行 ...

  9. webpack3.0之loader配置及编写(一)

    loader 用于对模块的源代码进行转换.loader 可以使你在 import 或"加载"模块时预处理文件.loader 可以将文件从不同的语言(如 TypeScript)转换为 ...

  10. 递推-练习1--noi1760 菲波那契数列(2)

    递推-练习1--noi1760 菲波那契数列(2) 一.心得 二.题目 1760:菲波那契数列(2) 总时间限制:  1000ms 内存限制:  65536kB 描述 菲波那契数列是指这样的数列: 数 ...