[英]How to Read File and Convert to Byte
I am currently study on AES, There are several good site explaining and giving example about AES Encryption in java such as this . 我目前的AES研究,有几个很好的网站解释,并给予例如约AES加密在Java中,如本 。 Example show AES encrypt String into byte.
示例显示AES将String加密为字节。
My question is how to convert application such as exe, txt and mp3? 我的问题是如何转换应用程序,例如exe,txt和mp3? I understand i have to convert the application into byte before encryption can be implement but how do you achieve that?
我知道我必须先将应用程序转换为字节,然后才能实施加密,但是您如何实现的呢?
The SO here and here explain about encrypt executable file but does not answer my question. 此处和此处的SO说明了有关加密可执行文件的信息,但未回答我的问题。
You should look into https://community.oracle.com/thread/2152253 link 您应该查看https://community.oracle.com/thread/2152253链接
Also refer How to read content of .EXE file in Java 另请参阅如何在Java中读取.EXE文件的内容
FileInputStream将文件读入字节数组。
You may use NIO2 for random access files . 您可以将NIO2用于随机访问文件 。 This will represent the file data with a
ByteBuffer
. 这将使用
ByteBuffer
表示文件数据。 This is generally more efficient than using streams. 通常,这比使用流更有效。 The Java encryption classes happily accommodate you by supplying encryption methods on
ByteBuffer
- update
and doFinal
specifically. Java加密类通过在
ByteBuffer
上提供加密方法(特别是update
和doFinal
愉快地适应您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.