NSData到Java字符串 [英] NSData to Java String

查看:343
本文介绍了NSData到Java字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在写一个Web应用程序与iPhone进行交互。 iPhone iphone实际上将以plist的形式发送信息到服务器。因此,看到类似的东西并不少见...

I've been writing a Web Application recently that interacts with iPhones. The iPhone iphone will actually send information to the server in the form of a plist. So it's not uncommon to see something like...

<key>RandomData</key>
<data>UW31vrxbUTl07PaDRDEln3EWTLojFFmsm7YuRAscirI=</data>



现在我知道这些数据是以某种方式散列/加密的。当我用编辑器(属性列表编辑器)打开plist时,它显示了一个更加可读的格式。例如,上面的数据将被转换成类似...的内容。

Now I know this data is hashed/encrypted in some fashion. When I open up the plist with an editor (Property List Editor), it shows me a more "human readable" format. For example, the data above would be converted into something like...

<346df5da 3c5b5259 74ecf683 4431249f 711630ba 232c54ac 9bf2ee44 0r1c8ab2>

任何想法转换的方法是什么?

Any idea what the method of converting it is? Mainly I'm looking to get this into a Java String.

谢谢!

推荐答案

在base64解码后,你需要对它进行十六进制编码。这是PL编辑器向你展示的。

After base64 decoding it you need to hex encode it. This is what PL Editor is showing you.

所以...

<key>SomeData</key>
<data>UW31ejxbelle7PaeRAEen3EWMLojbFmsm7LuRAscirI=</data?

可以用...表示

byte[] bytes = Base64.decode("UW31ejxbelle7PaeRAEen3EWMLojbFmsm7LuRAscirI=");
BigInteger bigInt = new BigInteger(bytes);
String hexString = bigInt.toString(16);
System.out.println(hexString);

获取...

<516df5aa 3c5b5259 74ecf683 4401259f 711630ba 236c59ac 9bb2ee44 0b1c8ab2>

这篇关于NSData到Java字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆