tob*_*ias 8 php android md5 diacritics
我使用md5来保护我的帖子到运行PHP的后端服务器.参数通过HTTP Post发送.
我有一个问题,我的md5计算结果在Android和PHP服务器上是不同的,如果其中一个输入参数中有ü,ä或ö.
在Android上,哈希是通过此函数计算的:
public static final String md5(final String s) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest
.getInstance("MD5");
digest.update(s.getBytes());
byte messageDigest[] = digest.digest();
// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < messageDigest.length; i++) {
String h = Integer.toHexString(0xFF & messageDigest[i]);
while (h.length() < 2)
h = "0" + h;
hexString.append(h);
}
return hexString.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return "";
}
Run Code Online (Sandbox Code Playgroud)
在我只是使用的PHP服务器上
md5() function.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4958 次 |
| 最近记录: |