Skip to content

darkerk/Encryption

Repository files navigation

// 加密文件事例

NSString *docDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *toPath = [docDir stringByAppendingPathComponent:@"database.db"];

NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:toPath]) {
    NSString *inPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.db"];

    NSError  *error = nil;
    if (![[NSFileManager defaultManager] AESEncryptFile:inPath toFile:toPath usingPassphrase:@"password" error:&error])
    {
        NSLog(@"加密文件失败:%@", [[error userInfo] objectForKey:AESEncryptionErrorDescriptionKey]);
    }

/************** if (![[NSFileManager defaultManager] AESDecryptFile:inPath toFile:toPath usingPassphrase:@"password" error:&error]) { NSLog(@"解密文件失败:%@", [[error userInfo] objectForKey:AESEncryptionErrorDescriptionKey]); } ***************/ }

About

AES加密文件

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published