Skip to content

xxtea/xxtea-objc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XXTEA for Objective-C

XXTEA logo

Join the chat at https://gitter.im/xxtea/xxtea-objc CocoaPods CocoaPods CocoaPods

Introduction

XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for Objective-C.

It is different from the original XXTEA encryption algorithm. It encrypts and decrypts NSData instead of 32bit integer array, and the key is also the NSData.

In addition to providing the API of NSData encryption and decryption, it also provides some methods to handle NSString and Base64 encode.

Installation

git clone https://github.com/xxtea/xxtea-objc.git

Usage

#import <Foundation/Foundation.h>
#import "XXTEA.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSString *text = @"Hello World! 你好,中国!";
        NSData *key = [@"1234567890" dataUsingEncoding:NSASCIIStringEncoding];
        NSData *encrypt_data = [[text dataUsingEncoding:NSUTF8StringEncoding] xxteaEncrypt:key];
        NSData *decrypt_data = [encrypt_data xxteaDecrypt:key];
        if (strncmp([text UTF8String], decrypt_data.bytes, decrypt_data.length) == 0) {
            NSLog(@"success!");
        }
        else {
            NSLog(@"fail!");
        }
    }
    return 0;
}

About

XXTEA encryption algorithm library for Objective-C.

Resources

License

Stars

Watchers

Forks

Packages

No packages published