Cipher pad block corrupted on Gingerbread

前端 未结 3 1582
小鲜肉
小鲜肉 2021-02-04 23:02

I believe this is a snippet from androidsnippets.org - why this isn\'t funcioning on Android 2.3? How to fix it?

Error

3条回答
  •  再見小時候
    2021-02-04 23:30

    Two points:

    1) The toByte() method isn't clear what it's trying to do, but I'll bet it's wrong, as the line

    int len = hexString.length()/2;
    

    is going to give the same result of 3 for strings of length 6 and 7 (say)

    2) You can't rely on converting stings to byte arrays without specifying the Charset to use. Different locales and different run machines may have different default Charsets. You should probably use str.getBytes("UTF8") in the algorithm.

提交回复
热议问题