开发者

Differences with result?

I have used a small snippet to encode, and decode a string using AES128. The issue is that it appears, that there are differences when I encode and decode on different platforms. If I run the same code on the android SDK or on the computer, I seem to get different results, even if I use the same seed/ha开发者_StackOverflow中文版sh.

To clarify, the execution result (the encrypted value) differs from one platform to the other. In android, I get another value, and in a standard java application, I get another one.

What could possibly be wrong?

http://www.androidsnippets.com/encryptdecrypt-strings


Welcome to Stackoverflow, first just a housekeeping point, it's best not to use the 'answer' option here for replying to comments, just click 'add comment'.

Have a look at this link for an example of encryption Encrypting a String with DES

Note the way the getBytes is qualified with "UTF8". It's then base64 encoded. Some higher levels of Android (API and onwards) have the base64 built in, otherwise it's easy enough to write your own, or just Google for Java + bas64 + example. If you use this sample code it should give you the same result on both platforms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜