项目作者: pkuoliver

项目描述 :
AES encrypt/decrypt, Android, iOS, php compatible(兼容php, Android, iOS平台)
高级语言: Objective-C
项目地址: git://github.com/pkuoliver/EasyAES.git
创建时间: 2017-04-17T10:50:08Z
项目社区:https://github.com/pkuoliver/EasyAES

开源协议:

下载


EasyAES

AES encrypt/decrypt library, Android, iOS, PHP, Python, C# compatible.

Data can be encrypted and decrypted between five platforms, and data encrypted on one platform can be decrypted on the other four platforms.

中文版说明

Usage

Android:

  1. String text = "this is plain text.";
  2. EasyAES aes = new EasyAES("password here", 256, "iv here");
  3. // encrypt
  4. String data = aes.encrypt(text);
  5. // decrypt
  6. String plainText = aes.decrypt(data);

PHP:

  1. $text = "this is plain text.";
  2. $aes = new EasyAES('password here', 256, 'iv here');
  3. // encrypt
  4. $data = $aes->encrypt($text);
  5. // decrypt
  6. $plainText = $aes->decrypt($data);

Notes:The php5.x version uses the mcrypt extension, which needs to be installed and enabled in php.ini. php7.0 and above use the ssl module, so mcrypt is no longer required.

iOS

  1. EasyAES *aes = [[EasyAES alloc] initWithKey:@"your key" bit:256 andIV:@"your iv"];
  2. // encrypt
  3. NSString *data = [aes encrypt:text];
  4. // decrypt
  5. NSString *plainText = [aes decrypt:data];
  6. // encrypt/decrypt NSData
  7. NSData *pData = ...//encrypted data form server
  8. NSData *plainData = [aes decryptedData:pData];
  9. NSData *encData = [aes encryptedData:plainData];

Python

  1. text = "this is plain text."
  2. aes = EasyAES('password here', 256, 'iv here')
  3. # encrypt string
  4. data = aes.encrypt(text)
  5. # decrypt string
  6. plainText = aes.decrypt(data)

C

  1. string text = "this is plain text.";
  2. EasyAES aes = new EasyAES("password here", 256, "iv here");
  3. // encrypt
  4. string encText = aes.Encrypt(text);
  5. // decrypt
  6. string decText = aes.Decrypt(encText);

All of the above usage need to set own password and offset vector(iv).

128 bit or 256 bit

The 256-bit AES encryption algorithm has higher security, so it is strongly recommended to use the 256-bit encryption method, but it will cause some performance losses.

If you are very sensitive to performance, you can use the 128-bit method, just change the second parameter of the constructor to 128.

TODO List

Later plans to complete the C, C++ version, so stay tuned.

For more information, please visit my blog 帝都码农