Explorar el Código

1.修改RAUtils 增加MD5。

Pen Li hace 7 años
padre
commit
e94fa15913
Se han modificado 2 ficheros con 17 adiciones y 0 borrados
  1. 3 0
      RedAnt ERP Mobile/common/RAUtils.h
  2. 14 0
      RedAnt ERP Mobile/common/RAUtils.m

+ 3 - 0
RedAnt ERP Mobile/common/RAUtils.h

@@ -74,4 +74,7 @@
 
 
 + (CGRect)relativeFrame:(CGRect) frame FromView:(UIView *)v toView:(UIView*)tv;
+
++ (nullable NSString *)md5:(nullable NSString *)str;
+
 @end

+ 14 - 0
RedAnt ERP Mobile/common/RAUtils.m

@@ -917,6 +917,20 @@ done:
     return tempate;
 }
 
++ (nullable NSString *)md5:(nullable NSString *)str {
+    if (!str) return nil;
+    
+    const char *cStr = str.UTF8String;
+    unsigned char result[CC_MD5_DIGEST_LENGTH];
+    CC_MD5(cStr, (CC_LONG)strlen(cStr), result);
+    
+    NSMutableString *md5Str = [NSMutableString string];
+    for (int i = 0; i < CC_MD5_DIGEST_LENGTH; ++i) {
+        [md5Str appendFormat:@"%02x", result[i]];
+    }
+    return md5Str;
+}
+
 @end