你的位置:首页 > 操作系统

[操作系统]【代码笔记】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