I believe this is a snippet from androidsnippets.org - why this isn\'t funcioning on Android 2.3? How to fix it?
Error
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.