1

我想在 iOS 中加密密码。

NSData *dataIn = [@"Now is the time for all good computers to come to the aid of their masters." dataUsingEncoding:NSASCIIStringEncoding];
NSMutableData *macOut = [NSMutableData dataWithLength:CC_SHA256_DIGEST_LENGTH];

CC_SHA256(dataIn.bytes, dataIn.length,  macOut.mutableBytes);

NSLog(@"dataIn: %@", dataIn);
NSLog(@"macOut: %@", macOut);

我想用指定的键创建。有没有办法做到这一点。

谢谢。

4

3 回答 3

0

你实际上并没有加密你的字符串,只使用 SHA2 散列。要使用真实密钥进行加密,您应该使用 CCCrypt() 进行实际加密。

我建议看:http: //developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man3/CCCrypt.3cc.html

于 2013-02-06T11:48:18.470 回答
-1

使用OpenSSL库加解密: https ://github.com/zeeshankhan/ZKOpenSSLPlay

于 2016-06-22T04:29:51.853 回答
-2

如果可以使用 NSString,你可以下载 NSString Additions。

好教程在这里

于 2013-02-06T10:47:57.393 回答