Base64 of encryption

Source: Internet
Author: User


    • Is the most widely used encoding system on the network, capable of converting any binary data into a 65-character text file
    • a~z,A~Z,0~9,+,/,=
    • Base 64The encoded result can be reversed, not safe enough
    • Base 64is the basic algorithm for all modern cryptographic algorithms
Terminal commands
# 将 10.jpg 进行 base64 编码,生成 10.txt 文件$ base64 10.jpg -o 10.txt# 将 10.txt 解码生成 1.jpg 文件$ base64 -D 10.txt -o 1.jpg# 将字符串 Man 进行 base64 编码$ echo -n "Man" | base64# 将字符串 TWFu 解码$ echo -n "TWFu" | base64 -D
Code implementation
///  BASE 64 编码- (NSString *)base64Encode:(NSString *)string {    NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];    return [data base64EncodedStringWithOptions:0];}/// BASE 64 解码- (NSString *)base64Decode:(NSString *)string { NSData *data = [[NSData alloc] initWithBase64EncodedString:string options:0]; return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];}
Save & Load User Information
Save User Information-(void) Saveuserinfo {Nsuserdefaults *defaults = [Nsuserdefaults Standarduserdefaults];IOS 8.0 will be written directly to the sandbox without any further use of ' [Defaults synchronize]; ' [Defaults setobject:self. Username Forkey:hmusernamekey]; NSString *pwd = [selfbase64encode:self. pwd]; [Defaults setobject:pwd forkey:hmuserpasswordkey];} ///load user under information-(void) loaduserinfo { Nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults]; self. Usernametext. Text = [Defaults stringforkey:hmusernamekey]; self. Pwdtext. Text = [selfbase64decode:[defaults stringforkey:hmuserpasswordkey];}   
Problems that exist
    1. Use Base64 clear text that does not directly see the user's password
    2. But Base64 the algorithm is public, and the algorithm is reversible, the security is not good

Base64 of encryption

Related Article

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.