HashCalcの上部には「データ形式」というフィールドがあり、それを「HexString」に切り替えてから9a
、データ フィールドにテスト値を入力します。SHA-1 ハッシュを実行すると、答えは次のようになります。13cba177bcfad90e7b3de70616b2e54ba4bb107f
(注: オンライン ハッシャーは "9a" を文字列としてハッシュし、結果としてe8eef065fb7295044d65b305bab18a9a645d1abf
. このアプリケーションでは間違っています)
ここで、このタイプのハッシュを Java プログラムに埋め込む必要があります。これは私がこれまでに得たものです(try/catchにラップされています):
String ss = "9a";
ByteBuffer bb = ByteBuffer.allocate(8);
byte[] ba = bb.putLong(Long.decode("0x"+ss).longValue()).array();
MessageDigest md = MessageDigest.getInstance("SHA-1");
String results = encodeHex(md.digest(ba));
System.out.println("sha:"+results);
しかし、私の結果はE73C417858807239DD5BC30BA978C14D57F80834
私は何を間違っていますか?
編集: 16 進タグを追加しました。データが何らかの 16 進形式でなければならないことは明らかです。HashCalc は、別の結果を返す「TextString」ではなく「HexString」に設定する必要があるためです。そして、解決策には、これらの 16 進数の処理方法の変更が含まれる可能性があります。--> 事実であることが判明しました