我想解密使用Microsoft CryptoAPI的CryptEncrypt函數加密的Java文件。我已經讀過:「返回的加密塊緩衝區採用小端字節順序(與上面的Java和.NET的big-endian相比)。」java的ByteOrder小endian大endian不工作?
我正在使用Java中的ByteBuffer和ByteOrder類,並且很確定我做錯了,因爲無論我嘗試什麼,我都會得到與System.out.println相同的打印輸出以用於beforebytes和afterbytes。
byte [] beforebytes = null;
// code to extract bytes from file here
ByteBuffer bb = ByteBuffer.wrap(beforebytes);
bb.order(ByteOrder.LITTLE_ENDIAN); // BIG_ENDIAN doesn't work either?
ByteBuffer slice = bb.slice();
// 'slice' now refers to the same data, but is supposed to be BIG ENDIAN
byte[] afterbytes = new byte[bb.capacity()];
// transfer bytes from this buffer into the given destination array
slice.get(afterbytes, 0, afterbytes.length);
任何幫助將不勝感激!
謝謝 貝特朗
你可以在你的問題的正文中包括你嘗試過的東西嗎? – Newd
嗨Newd,我試過ByteOrder.BIG_ENDIAN。我嘗試過和沒有切片。我也嘗試了其他明顯錯誤的東西;) –