将AES256与xml一起使用

时间:2011-06-29 15:30:16

标签: objective-c

我想加密我的数据并将其保存在XML文件中 但是当我使用这段代码时,我遇到了问题。

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    self.party = [PartyParser loadParty];   



    NSString *plainString = @"This string will be encrypted";
    NSString *key = @"EUROTUN"; // should be provided by a user
    NSLog( @"Original String: %@", plainString );

    NSString *encryptedString = [plainString AES256EncryptWithKey:key];
    NSLog( @"Encrypted String: %@", encryptedString );

    [_party.players addObject:[[[Player alloc] initWithName:encryptedString level:1             rpgClass:RPGClassRogue] autorelease]];
    [PartyParser saveParty:_party];

    if (_party != nil) {
        for (Player *player in _party.players) {
            NSString * strData1 =player.name;
            NSLog( @"Decrypted String: %@",  strData1 );
        }
        // Add a new party member, for fun
    }

    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}

0 个答案:

没有答案