简体   繁体   English

在android中加密解密

[英]Encryption an decryption in android

I am new in android.I want to encrypt a file and I want to decrypt it an show it in a image view can anyone help me. 我是android的新手。我想加密一个文件,我想解密它在图像视图中显示它可以任何人帮助我。 I have no idea about the encryption and decryption. 我不知道加密和解密。

If you have a File of the file on the SD card , you can read it into a byte[] , and do realImageContents = decrypt(fileContents) for some function decrypt() . 如果SD卡上File文件 ,可以将其读入byte[] ,并为某些函数decrypt()执行realImageContents = decrypt(fileContents) decrypt() Then you can get a Bitmap object using BitmapFactory and pass that to ImageView.setImageBitmap() . 然后,您可以使用BitmapFactory获取一个Bitmap对象,并将其传递给ImageView.setImageBitmap()

Look at javax.crypto for using actual encryption algorithms. 查看javax.crypto以了解使用实际的加密算法。 If you just want to obfuscate the image, you could just write your own encrypt() / decrypt() that does something simple like an XOR cipher with the key hard-coded in your application. 如果你只想混淆图像,你可以编写自己的encrypt() / decrypt() ,它可以像你的应用程序中硬编码的密钥一样简单地执行XOR密码

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

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