需要做加密AES256
Need to do Encryption AES256
如何通过 iso10126padding 和 CBC 模式在 AES 256 中加密 NSDATA,需要像 android.Please 这样的密码来帮助使用 AES256 加密对 NSData 进行加密。
转到这个问题它会对你有所帮助:AES Encryption for an NSString on the iPhone
或转到:https://github.com/RNCryptor/RNCryptor
在Objective-C
Obj-C
//
// Encryption
//
NSString *password = @"Secret password";
RNEncryptor *encryptor = [[RNEncryptor alloc] initWithPassword:password];
NSMutableData *ciphertext = [NSMutableData new];
// ... Each time data comes in, update the encryptor and accumulate some ciphertext ...
[ciphertext appendData:[encryptor updateWithData:data]];
// ... When data is done, finish up ...
[ciphertext appendData:[encryptor finalData]];
//
// Decryption
//
RNDecryptor *decryptor = [[RNDecryptor alloc] initWithPassword:password];
NSMutableData *plaintext = [NSMutableData new];
// ... Each time data comes in, update the decryptor and accumulate some plaintext ...
NSError *error = nil;
NSData *partialPlaintext = [decryptor updateWithData:data error:&error];
if (error != nil) {
NSLog(@"FAILED DECRYPT: %@", error);
return;
}
[plaintext appendData:partialPlaintext];
// ... When data is done, finish up ...
NSError *error = nil;
NSData *partialPlaintext = [decryptor finalDataAndReturnError:&error];
if (error != nil) {
NSLog(@"FAILED DECRYPT: %@", error);
return;
}
[ciphertext appendData:partialPlaintext];
您可以将属性设置为 Transformable 并使用您自己的 Transformer class 来应用 encryption/decryption。
这是可转换属性指南:
enter link description here
如何通过 iso10126padding 和 CBC 模式在 AES 256 中加密 NSDATA,需要像 android.Please 这样的密码来帮助使用 AES256 加密对 NSData 进行加密。
转到这个问题它会对你有所帮助:AES Encryption for an NSString on the iPhone
或转到:https://github.com/RNCryptor/RNCryptor
在Objective-C
Obj-C
//
// Encryption
//
NSString *password = @"Secret password";
RNEncryptor *encryptor = [[RNEncryptor alloc] initWithPassword:password];
NSMutableData *ciphertext = [NSMutableData new];
// ... Each time data comes in, update the encryptor and accumulate some ciphertext ...
[ciphertext appendData:[encryptor updateWithData:data]];
// ... When data is done, finish up ...
[ciphertext appendData:[encryptor finalData]];
//
// Decryption
//
RNDecryptor *decryptor = [[RNDecryptor alloc] initWithPassword:password];
NSMutableData *plaintext = [NSMutableData new];
// ... Each time data comes in, update the decryptor and accumulate some plaintext ...
NSError *error = nil;
NSData *partialPlaintext = [decryptor updateWithData:data error:&error];
if (error != nil) {
NSLog(@"FAILED DECRYPT: %@", error);
return;
}
[plaintext appendData:partialPlaintext];
// ... When data is done, finish up ...
NSError *error = nil;
NSData *partialPlaintext = [decryptor finalDataAndReturnError:&error];
if (error != nil) {
NSLog(@"FAILED DECRYPT: %@", error);
return;
}
[ciphertext appendData:partialPlaintext];
您可以将属性设置为 Transformable 并使用您自己的 Transformer class 来应用 encryption/decryption。
这是可转换属性指南: enter link description here