我想解密使用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。我尝试过和没有切片。我也尝试了其他明显错误的东西;) –