iOS代码加密常用加密方式

iOS代码加密常用加密方式,常见的iOS代码加密常用加密方式算法包括MD5加密、AES加密、BASE64加密,三大算法iOS代码加密是如何进行加密的,且看下文

MD5 iOS代码加密

  1. :1:

  2. MD5 iOS代码加密

    创建MD5类,代码如下

    #import <Foundation/Foundation.h>

    @interface CJMD5 : NSObject

    +(NSString *)md5HexDigest:(NSString *)input;

    @end

  3. 2:

  4. #import "CJMD5.h"

    #import <CommonCrypto/CommonDigest.h>

    @implementation CJMD5

    +(NSString *)md5HexDigest:(NSString *)input{

        

        const char* str = [input UTF8String];

        unsigned char result[CC_MD5_DIGEST_LENGTH];

        CC_MD5(str, strlen(str), result);

        NSMutableString *ret = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH];

        

        for(int i = 0; i<CC_MD5_DIGEST_LENGTH; i++) {

            [ret appendFormat:@"%02X",result];

        }

        return ret;

    }

    @end

  5. 3:

    MD5是不可逆的只有加密没有解密,iOS代码加密使用方式如下

    NSString *userName = @"cerastes";

    NSString *password = @"hello Word";

    //   MD5加密

    NSString *md5 = [CJMD5 md5HexDigest:password];

    NSLog(@"%@",md5);

猜你喜欢

转载自blog.csdn.net/weixin_44904409/article/details/89355402
今日推荐