0

I am trying to implement an OTP generator for Blackberry OS10. I already use the reference implementation on Android side, you can find it here:

So I would like to convert it to C++ / QNX code and I have some troubles with hexadecimal conversion...

In java:

private static byte[] hexStr2Bytes(String hex){
     // Adding one byte to get the right conversion
     // Values starting with "0" can be converted
     byte[] bArray = new BigInteger("10" + hex,16).toByteArray();

     // Copy all the REAL bytes, not the "first"
     byte[] ret = new byte[bArray.length - 1];
     for (int i = 0; i < ret.length; i++)
         ret[i] = bArray[i+1];
     return ret;
 }

In QNX:

QByteArray msg = QByteArray::fromHex(m.toLocal8Bit());

Problem is "m" start with '00' and so my final msg array is 0 length...

For example I try to encode the hex qstring:0000000002ca4e32

In blackberry: m=""

In Android: m="?M?"

So you can someone explain me how to deal with such a conversion ?

Thanks!

4

1 回答 1

0

我要做的是将您的 Java 函数转换为纯 C++,即不是 QT 格式。然后将数据类型适应QT。

于 2014-07-03T11:17:44.047 回答