首页 > 移动平台 > 详细

iOS之 那几种加密 Base64

时间:2016-03-26 22:14:05      阅读:284      评论:0      收藏:0      [点我收藏+]

技术分享

 

 

ViewController.m
//
//  ViewController.m
//  Base64
//
//  Created by dllo on 16/1/12.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "ViewController.h"
#import "GTMBase64.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    
    [self Base64];
    
}

- (void)Base64{
    //对字符串进行加密,实质上是进行BASE64编码.
    NSString *encodStr = [GTMBase64 encodeBase64String:@"wanghaiteng504"];
    NSLog(@"%@",encodStr); /*加密完毕,打印看看,编码后的效果*/
    
    //解密
    NSString *decodeStr = [GTMBase64 decodeBase64String:encodStr];
    NSLog(@"%@",decodeStr);
    

//    
//    //字典加密
//    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"583267034",@"Username",@"wanghaiteng504",@"Userpass", nil];
//    //字典转化为Data
//    NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
//    NSData *encodeData = [GTMBase64 encodeData:data];
//    NSLog(@"%@",encodeData);
//    
//    //解密
//    NSData *decodeData = [GTMBase64 decodeData:encodeData];
//    NSDictionary *di = [NSJSONSerialization JSONObjectWithData:decodeData options:0 error:nil];
//    NSLog(@"%@",di);
    
}




@end

 

iOS之 那几种加密 Base64

原文:http://www.cnblogs.com/HaiTeng/p/5324118.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!