//
//  NSString+Base64.m
//  GMAlpha
//
//  Created by ioszhb on 2019/1/18.
//  Copyright © 2019 Gengmei. All rights reserved.
//

#import "NSString+Base64.h"

@implementation NSString (Base64)
//base64编码
- (NSString *)encodeString:(NSString *)string
{
    NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
    NSString *encodedStr = [data base64EncodedStringWithOptions:0];
    return encodedStr;
}

//base64解码
- (NSString *)decodeString:(NSString *)string
{
    NSData *data = [[NSData alloc] initWithBase64EncodedString:string options:0];
    NSString *decodedStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    return decodedStr;
}


//base64编码
- (NSString *)str_base64Encode
{
    NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
    NSString *encodedStr = [data base64EncodedStringWithOptions:0];
    return encodedStr;
}

//base64解码
- (NSString *)str_base64Decode
{
    NSData *data = [[NSData alloc] initWithBase64EncodedString:self options:0];
    NSString *decodedStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    return decodedStr;
}


@end
