Skip to content

Instantly share code, notes, and snippets.

View charpty's full-sized avatar
🏠
Working from home

七飒 charpty

🏠
Working from home
  • H3C
  • Hangzhou City, Zhejiang Province, China
View GitHub Profile
// http://stackoverflow.com/questions/17535918/aes-gets-different-results-in-ios-and-java
- (NSData *)AES256EncryptWithKey:(NSString *)key {
// 'key' should be 32 bytes for AES256, will be null-padded otherwise
char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
// fetch key data
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];