NSData 到 Java 字符串
我最近一直在编写一个与 iPhone 交互的 Web 应用程序。 iPhone iphone实际上会以plist的形式向服务器发送信息。因此,看到类似的情况并不少见......
<key>RandomData</key>
<data>UW31vrxbUTl07PaDRDEln3EWTLojFFmsm7YuRAscirI=</data>
现在我知道这些数据以某种方式进行了散列/加密。当我使用编辑器(属性列表编辑器)打开 plist 时,它向我显示了一种更“人类可读”的格式。例如,上面的数据将被转换成类似的东西......
<346df5da 3c5b5259 74ecf683 4431249f 711630ba 232c54ac 9bf2ee44 0r1c8ab2>
知道转换它的方法是什么吗?主要是我希望将其转换为 Java 字符串。
谢谢!
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>
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.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我们 wikipedia 的朋友的说法,
标签包含 Base64 编码 数据。因此,使用您最喜欢的 Java“Base64”类进行解码(另请参阅此问题) 。
附:从技术上讲,这既不是“散列”也不是“加密”,只是“编码”。 “散列”意味着一种单向转换,其中多个输入值可以产生相同的输出值。 “加密”意味着需要(通常是秘密的)“密钥”来反转加密。 Base64 编码只是一种仅使用可打印字符来表示任意二进制数据的方法。
According to our friends at wikipedia, the
<data>
tag contains Base64 encoded data. So, use your favorite Java "Base64" class to decode (see also this question).ps. technically, this is neither "hashed" nor "encrypted", simply "encoded". "Hashed" implies a one-way transformation where multiple input values can yield the same output value. "Encrypted" implies the need for a (usually secret) "key" to reverse the encryption. Base64 encoding is simply a way of representing arbitrary binary data using only printable characters.
Base64 解码后,您需要对其进行十六进制编码。这就是 PL Editor 向您展示的内容。
所以...
可以表示为...
以获得...
After base64 decoding it you need to hex encode it. This is what PL Editor is showing you.
So...
Can be represented with...
To get...