2013-05-06 40 views
0

這裏只是一個簡短的問題,我想知道把我的註冊碼放到服務器上的用戶的最佳位置。我正在加密它看到here隱藏iOS上用戶的註冊碼

//encrypting 
NSString* strToEncrypt =NewPINField.text 
NSString* theKey = @\"KeyKeyKeyKey\"; 
NSData* dataToEncrypt = [strToEncrypt dataUsingEncoding: NSUTF8StringEncoding]; 
NSData *encryptedData = [dataToEncrypt EncryptWithKey: theKey]; 
NSLog(@\"Encrypted data: %@\", encryptedData); 


//decrypting 
NSData* encryptedData = (NSData*)[profileData objectForKey:@\"PIN\"]; 
NSString* theKey = @\"KeyKeyKeyKey\"; //notice this is the same as above. It MUST be 
NSData *decData = [encryptedData DecryptWithKey: theKey ]; 
currentPIN = [NSString stringWithUTF8String:[decData bytes]]; 

NSLog(@\"Decrypted pin: %@\", currentPIN); 

唯一的其他規範是隱藏它/把它放在一個沒有認識的地方。 我需要保存狀態,所以它需要某種plist,我只是想知道是否有辦法隱藏它比直接添加到我的plist文件好一點。

你會做什麼?

任何幫助將不勝感激。

回答

1

如果您需要安全地存儲數據,我強烈建議使用鑰匙串。有一個關於在這裏創建一個基本鑰匙串應用程序的教程:http://www.raywenderlich.com/6475/basic-security-in-ios-5-tutorial-part-1

您可以安全地將數據存儲在鑰匙串中,而不用擔心先加密它,因爲這是由OS處理的。但你可以,如果你想。

在實現安全,從來沒有試圖隱藏的東西在那裏會有人不看:http://en.wikipedia.org/wiki/Security_through_obscurity

+0

LOL感謝兆一堆..現在要了解這一點。我一直在加密研究堆,但這正是我需要thankyoU! – HurkNburkS 2013-05-06 23:02:08