简体   繁体   English

通过HTTP将字节数组从Android发送到服务器端PHP脚本

[英]Sending a byte array over HTTP from Android to server-side PHP script

I have an Android application which use AES encryption to encrypt a password. 我有一个使用AES加密来加密密码的Android应用程序。 I have a key in my app and I generate a random IV for each encryption, and I will use this IV to decrypt the password in a php file. 我在我的应用程序中有一个密钥,并且为每种加密生成一个随机IV,并且我将使用该IV解密php文件中的密码。

In the android application, the IV is a byte[] and I don't know how to send it via http request. 在android应用程序中,IV是一个byte [],我不知道如何通过http请求发送它。

I think I have to encode it because the byte[] generated is not convertible in a String to send it easily but I don't know how. 我想我必须对其进行编码,因为生成的byte []不能在String中转换为轻松发送,但我不知道如何。

I was thinking to send it with a ByteArrayEntity but I can't give a name to this POST parameter so I can't receive it from my PHP file. 我当时想使用ByteArrayEntity来发送它,但是无法给该POST参数指定名称,因此无法从我的PHP文件中接收它。

If you have any idea, can you help me please ? 如果您有任何想法,请您能帮我吗?

Thanks in advance 提前致谢

Use base64 encoding. 使用base64编码。 Both android and java provide mechanisms to encode and decode bae64 strings into usable formats for their respective encryption mechanisms. android和java都提供了将bae64字符串编码和解码为可用格式的机制,以用于其各自的加密机制。

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

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