Skip to content

AES encrypt/decrypt, Android, iOS, php, Python, C# compatible(兼容php, Android, iOS, Python平台)

Notifications You must be signed in to change notification settings

pkuoliver/EasyAES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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

PHP:

$text = "this is plain text.";
$aes = new EasyAES('password here', 256, 'iv here');
// encrypt
$data = $aes->encrypt($text);
// decrypt
$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

EasyAES *aes = [[EasyAES alloc] initWithKey:@"your key" bit:256 andIV:@"your iv"];
// encrypt
NSString *data = [aes encrypt:text];
// decrypt
NSString *plainText = [aes decrypt:data];

// encrypt/decrypt NSData
NSData *pData = ...//encrypted data form server
NSData *plainData = [aes decryptedData:pData];
NSData *encData = [aes encryptedData:plainData];

Python

text = "this is plain text."
aes = EasyAES('password here', 256, 'iv here')
# encrypt string
data = aes.encrypt(text)
# decrypt string
plainText = aes.decrypt(data)

C#

string text = "this is plain text.";
EasyAES aes = new EasyAES("password here", 256, "iv here");
// encrypt
string encText = aes.Encrypt(text);
// decrypt
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 帝都码农

About

AES encrypt/decrypt, Android, iOS, php, Python, C# compatible(兼容php, Android, iOS, Python平台)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published