Giter VIP home page Giter VIP logo

basetool's Introduction

基础工具

字符串时间格式化

getCurrentTimesWithNowDate


以sss为单位的时时间戳

getNowTimeTimestampWithNowDate


检查字符非空 nil null @‘’ null>

judgeBlankString


根据正则表达式校验字符串

validateStr:withRegex


字符串md5加密

+ (NSString *)md5:(NSString *)input{
   const char *cStr = [input UTF8String];
   
   unsigned char digest[CC_MD5_DIGEST_LENGTH];
   
   CC_MD5( cStr, strlen(cStr), digest ); // This is the md5 call
   
   NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
   
   for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
       
       [output appendFormat:@"%02x", digest[i]];
   
   return  output;
}


字符串sha1加密

+ (NSString *)sha1:(NSString *)inputString{
    const char *cstr = [inputString cStringUsingEncoding:NSUTF8StringEncoding];
    NSData *data = [NSData dataWithBytes:cstr length:inputString.length];
    uint8_t digest[CC_SHA1_DIGEST_LENGTH];
    CC_SHA1(data.bytes,(unsigned int)data.length,digest);
    NSMutableString *outputString = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
    
    for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
        [outputString appendFormat:@"%02x",digest[i]];
    }
    return outputString;
}

app内拨打电话

+ (void)telWithPhone:(NSString *)tel{
   NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"telprompt://%@",tel];

   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}


清除缓存文件

getNowTimeTimestampWithNowDate


文件大小转换 m/kb/b

+ (NSString *)fileSizeConversion:(NSInteger)totalSize {
   
   NSString *totleStr = nil;
   if (totalSize > 1000 * 1000) {
       totleStr = [NSString stringWithFormat:@"%.2fM",totalSize / 1000.00f /1000.00f];
       
   } else if (totalSize > 1000) {
       totleStr = [NSString stringWithFormat:@"%.2fKB",totalSize / 1000.00f ];
       
   } else {
       totleStr = [NSString stringWithFormat:@"%.2fB",totalSize / 1.00f];
       
   }
   return totleStr;
}



计算缓存文件大小

getCacheSizeWithFilePath


校验简单手机号

valiMobile


basetool's People

Contributors

krysaya avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.