简体   繁体   English

如何在Android中存储密钥?

[英]How to store secret key in Android?

In my app I'm generating secret key based on device id + random garble.在我的应用程序中,我根据设备 ID + 随机乱码生成密钥。 What's safiest way to store those secret key in a way that it can be easily retrieved if user will transfer data from one device to another one?如果用户将数据从一个设备传输到另一个设备,那么以一种可以轻松检索的方式存储这些密钥的最安全方法是什么?

I'm talking about storing secret key in some external storage like: gmail or other server alike environment.我正在谈论将密钥存储在一些外部存储中,例如:gmail 或其他类似服务器的环境。

"easily transferred secret key" is an oxymoron, because the main purpose of the secret key is to be, well, impossible to guess or copy. “易于传输的密钥”是一个矛盾的说法,因为密钥的主要目的是,好吧,不可能猜测或复制。 that's why i'd recommend to generate the unique secret key on every user device and use them to encode your data stored on that particular device (and nowhere else).这就是为什么我建议在每个用户设备上生成唯一的密钥并使用它们来编码存储在该特定设备(而不是其他任何地方)上的数据。

when you transfer the data, you may ask the user to create the password, and encrypt transferred data with that password.当您传输数据时,您可以要求用户创建密码,并使用该密码对传输的数据进行加密。 and ask the user to enter the same password on the receiving device in order to decrypt the transfer and encrypt back again, but using the unique device key.并要求用户在接收设备上输入相同的密码以解密传输并再次加密,但使用唯一的设备密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM