xxtea / xxtea-objc Goto Github PK
View Code? Open in Web Editor NEWXXTEA encryption algorithm library for Objective-C.
License: MIT License
XXTEA encryption algorithm library for Objective-C.
License: MIT License
For example,for the following cases, a crash will occur
NSString *text = @"";
NSString *key = @"key";
for (int i = 0; i < 10000; i++) {
NSString *encrypt_data = [XXTEA encryptStringToBase64String:text stringKey:key];
NSString *decrypt_data = [XXTEA decryptBase64StringToString:encrypt_data stringKey:key];
NSLog(@"%@", encrypt_data);
NSLog(@"%d",i);
if ([text isEqual:decrypt_data]) {
NSLog(@"success!");
}
else {
NSLog(@"fail!");
}
}
Hi, 小马哥,我在使用的时候崩溃了,是这个 FIXED_KEY 宏 导致的,报了 stack buffer overflow detected 的错误,原因是我的 key超过了16位 了,memcpy 的时候就溢出了;因此需要做下调整,这是我修改的:
#define FIXED_KEY \
size_t i;\
uint8_t fixed_key[16];\
size_t cpyLength = key.length > 16 ? 16 : key.length;\
memcpy(fixed_key, key.bytes, cpyLength);\
for (i = cpyLength; i < 16; ++i) fixed_key[i] = 0;\
你好,我上次反馈了xxtea-objc对空串的加密有crash的风险
链接如下
#2
目前crash的问题是修复了,但是该库对空串的加密解密与其它端不一致了,我对比了一下java的实现与h5的实现,其它端对空串的加密结果是空串,对空串的解密结果也是空串,但是目前xxtea-objc不是,
xxtea-objc则是无论什么秘钥,空串的加密结果都是AAAAAA==
我想不管是什么语言,这种边界case的处理结果也应该保持一致吧?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.