NSData-AES Class Encryption/Decryption in Cocoa

后端 未结 1 1447
北海茫月
北海茫月 2020-11-29 23:55

I am attempting to encrypt/decrypt a plain text file in my text editor. encrypting seems to work fine, but the decrypting does not work, the text comes up encrypted. I am ce

相关标签:
1条回答
  • 2020-11-30 00:53

    Why not use the built-in encryption algorithms? Here's an NSData+AES i wrote which uses CCCrypt with a 256it key for AES256 encryption.

    You can use it like:

    NSData *data = [[NSData dataWithContentsOfFile:@"/etc/passwd"] 
                                 encryptWithString:@"mykey"];
    

    and decrypt it with:

    NSData *file = [data decryptWithString:@"mykey"];
    

    DISCLAIMER: There no guarantee my NSData+AES is bug-free :) It's fairly new. I welcome code reviews.

    0 讨论(0)
提交回复
热议问题