私はこれに数日間立ち往生しており、それを取得できないようです。ここに投稿することで、ひらめきを得て、投稿後 30 秒でこの問題を修正できることを願っています。:D ここに行きます....
文字列を暗号化し、URL に追加して、サーバーに送信する必要があります。手順は次のとおりです。
1. Build the string (for this post, I'm using a constant TEST string)
2. Get a CRC of the string and add that to the front of the string.
3. HEX the whole string.
4. Append to URL and connect over HTTP
私は2で立ち往生しています!! 私が取得すべき CRC は です1903129755
が、他の結果の中でも、取得しているのは です-1903129756
。注: この投稿では、テスト文字列とその結果の CRC を使用しています。ビルド時にミリ秒単位の時間を含めると、文字列が変化します。
また、これはブラックベリーに関するものです。Android コードは完璧に動作します。その CRC は、Android とオンラインの CRC ジェネレーター Web サイトの両方から取得されます。
http://hash.online-convert.com/crc32b-generator
私が持っているコードは他の人でもうまくいくように見えるので、ここでは明らかに私が間違っています。誰かが私のエラーを見つけることができますか?? ありがとう
ご覧のとおり、いくつかの異なる方法を試しました。
import net.rim.device.api.util.CRC32;
public long getCrcValue(String inputText)
{
int crc1 = 0,crc2=0;
long crc3=0;
crc1 = CRC32.update(CRC32.INITIAL_VALUE, inputText.getBytes());
crc2 = CRC32.update(0, inputText.getBytes());
String temp = Integer.toBinaryString(crc1);
crc3 = Long.parseLong(temp,2);
long crc4 = CRC32.update(CRC32.INITIAL_VALUE, inputText.getBytes());
long crc5 = CRC32.update(0, inputText.getBytes());
logger.log("CRC1 is: "+crc1);
logger.log("CRC2 is: "+crc2);
logger.log("CRC3 is: "+crc3);
logger.log("CRC4 is: "+crc4);
logger.log("CRC5 is: "+crc5);
return crc1;
}
PSlogger
は、カスタマイズされた形式の出力をコンソールに出力する独自のクラスなので、無視します。
編集:出力といえば、出力は次のとおりです。
CRC1 is: -1903129756
CRC2 is: -460833676
CRC3 is: 2391837540
CRC4 is: -1903129756
CRC5 is: -460833676
EDIT2: これは同等の Android コードです。注crc
は次のように定義されCRC32 crc
ます。
public long getCrcValue(String inputText)
{
crc.reset();
crc.update(inputText.getBytes());
return crc.getValue();
}