当前位置: 代码迷 >> Iphone >> 【代码札记】3DES+Base64加密解密
  详细解决方案

【代码札记】3DES+Base64加密解密

热度:245   发布时间:2016-04-25 05:27:51.0
【代码笔记】3DES+Base64加密解密

一,工程目录。

二,代码。

RootViewController.m

复制代码
#import "RootViewController.h"#import "NSString+TripleDES.h"#import "GTMBase64.h"@interface RootViewController ()@end@implementation RootViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    if (self) {        // Custom initialization    }    return self;}- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.        self.title=@"3DES+Base64";            //要加密的文字和密码   NSString *string=@"hello,World";   NSString *key=@"123456";           //加密    NSString *encryString=[NSString stringWithFormat:@"%@",[string EncryptTripleDESWithKey:key]];    NSLog(@"---string--%@",encryString);    //解密    NSString *decryString=[NSString stringWithFormat:@"%@",[encryString DecryptTripleDESWithKey:key]];    NSLog(@"--string--%@",decryString);    }- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}
复制代码

 

三,运行效果

2015-10-13 10:29:59.107 3DES+Base64加密解密[2277:66277] ---string--YDcteAUNvtE0PoB6hZpsKg==2015-10-13 10:29:59.108 3DES+Base64加密解密[2277:66277] --string--hello,World

 

  相关解决方案