2011-09-16 67 views
2

我必須將我的應用程序的私鑰存儲在android設備的安全位置,我閱讀了有關certStore的內容,但它不允許在其中存儲文件。 有沒有我可以安全地存儲它的位置,並且在應用程序重新安裝時不會被刪除。Android中的私鑰存儲

+0

你在應用程序中使用該鍵嗎? – user370305

+0

是的,我收到來自web的響應並用這個密鑰 – Mal

+0

進行解密,因此,在這種情況下,您只有一個選項是使用共享首選項,在私有模式下,則只有您的應用程序可以訪問此共享首選項。 – user370305

回答

1
You can store the key in the Preferences of your App. This will protect the key from 
getting read by other applications because of the underlying file system restrictions of 
the Android system. 

但是,這不會保護密鑰免於被用戶自己讀取。

如果您希望在您的應用程序被刪除並再次安裝到設備中後使用此共享首選項,請嘗試Android備份管理器。 我認爲它可以幫助你重新安裝你的活動數據。

EDIT: Android (unfortunately) does not provide a way to do so. The approach I've used 
     before is to encrypt this token with another key generated within the app. 

     Your app key can be algorithmically generated. This, however, is only as secure as 
     your algorithm. Once that is known this is equivalent to storing the token in plain text. 

謝謝。

+0

他們能夠訪問此文件夾,如果電話是植根? – Mal

+0

是的,如果電話是根源的,那麼他們可以訪問這個目錄。 – user370305

+0

但是如果你在你的活動或類中編寫了這個密鑰,並且一旦你的apk創建完成後,一旦使用了progaurd或任何其他安全工具,那麼我不認爲任何人都可以輕易得到它。 – user370305