您的位置:首页 > 编程语言

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

2015-11-30 08:36 393 查看
一,工程目录。



二,代码。

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: