简体   繁体   English

在Android中加密文件,然后在PC中解密

[英]Encrypt a file in Android then decrypt it in PC

I want to collect data and write in a encrypted file using public key (in Android). 我想使用公开密钥(在Android中)收集数据并写入加密文件。 Then I send file to PC to read. 然后,我将文件发送到PC进行读取。 In my PC I need to create an application to decrypt the file too. 在我的PC中,我还需要创建一个应用程序来解密文件。 How can I do and how to share key securely? 我该怎么办以及如何安全地共享密钥?

If you have encrypted file using Public key, file can be decrypted only using associated Private key. 如果您已使用公钥加密了文件,则只能使用关联的私钥来解密文件。 It is also called as Asymmetric Encryption. 也称为非对称加密。 But sending your application private key out of application context will be a severe security breach. 但是,从应用程序上下文发送应用程序私钥将是严重的安全漏洞。 Public keys are meant to be shared publicly, not the Private Key. 公钥旨在公开共享,而不是私钥。

In your case you can encrypt your file on android device using PC/Sever public key, send it to server and decrypt at server/PC using PC's Private key. 在您的情况下,您可以使用PC /服务器公共密钥在android设备上加密文件,将其发送到服务器,然后使用PC的私钥在服务器/ PC上解密。 This would be the only best solution. 这将是唯一的最佳解决方案。

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

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